From 52b61ebab8f05b72d6ff5f76c0929596cfccfa24 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Mon, 23 Jun 2014 14:48:12 -0700 Subject: [PATCH] added addModel() performance test --- tests/octree/src/ModelTests.cpp | 39 +++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tests/octree/src/ModelTests.cpp b/tests/octree/src/ModelTests.cpp index 391b54cea9..92b0b87cd8 100644 --- a/tests/octree/src/ModelTests.cpp +++ b/tests/octree/src/ModelTests.cpp @@ -213,6 +213,45 @@ void ModelTests::modelTreeTests(bool verbose) { qDebug() << "TIME - Test" << testsTaken <<":" << qPrintable(testName) << "elapsed=" << elapsedInMSecs << "msecs"; } + { + testsTaken++; + QString testName = "Performance - add model to tree 10,000 times"; + if (verbose) { + qDebug() << "Test" << testsTaken <<":" << qPrintable(testName); + } + + const int TEST_ITERATIONS = 10000; + quint64 start = usecTimestampNow(); + for (int i = 0; i < TEST_ITERATIONS; i++) { + uint32_t id = i + 2; // make sure it doesn't collide with previous model ids + ModelItemID modelID(id); + modelID.isKnownID = false; // this is a temporary workaround to allow local tree models to be added with known IDs + + float randomX = randFloatInRange(0.0f ,(float)TREE_SCALE); + float randomY = randFloatInRange(0.0f ,(float)TREE_SCALE); + float randomZ = randFloatInRange(0.0f ,(float)TREE_SCALE); + glm::vec3 randomPositionInMeters(randomX,randomY,randomZ); + + properties.setPosition(randomPositionInMeters); + properties.setRadius(halfMeter); + properties.setModelURL("https://s3-us-west-1.amazonaws.com/highfidelity-public/ozan/theater.fbx"); + + tree.addModel(modelID, properties); + } + quint64 end = usecTimestampNow(); + + bool passed = true; + if (passed) { + testsPassed++; + } else { + testsFailed++; + qDebug() << "FAILED - Test" << testsTaken <<":" << qPrintable(testName); + } + float USECS_PER_MSECS = 1000.0f; + float elapsedInMSecs = (float)(end - start) / USECS_PER_MSECS; + qDebug() << "TIME - Test" << testsTaken <<":" << qPrintable(testName) << "elapsed=" << elapsedInMSecs << "msecs"; + } + qDebug() << " tests passed:" << testsPassed << "out of" << testsTaken; if (verbose) { qDebug() << "******************************************************************************************";