From d6640f64d050a1a9bf1e29a515904d9ce5a5e2b9 Mon Sep 17 00:00:00 2001 From: Matt Williams Date: Sat, 27 Oct 2012 21:37:54 +0100 Subject: [PATCH] Add benchmark annotations to the tests This will affect total running times simce some tests will be run multiple times but it allows precise becnhmarking. --- tests/TestAStarPathfinder.cpp | 4 +++- tests/TestAmbientOcclusionGenerator.cpp | 4 +++- tests/TestCubicSurfaceExtractor.cpp | 4 +++- tests/TestLowPassFilter.cpp | 4 +++- tests/TestSurfaceExtractor.cpp | 4 +++- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/tests/TestAStarPathfinder.cpp b/tests/TestAStarPathfinder.cpp index 6f77e680..9493beb5 100644 --- a/tests/TestAStarPathfinder.cpp +++ b/tests/TestAStarPathfinder.cpp @@ -154,7 +154,9 @@ void TestAStarPathfinder::testExecute() AStarPathfinder< RawVolume > pathfinder(params); //Execute the pathfinder. - pathfinder.execute(); + QBENCHMARK { + pathfinder.execute(); + } //Make sure the right number of steps were created. QCOMPARE(result.size(), static_cast(24)); diff --git a/tests/TestAmbientOcclusionGenerator.cpp b/tests/TestAmbientOcclusionGenerator.cpp index 65367da7..42f34a1f 100644 --- a/tests/TestAmbientOcclusionGenerator.cpp +++ b/tests/TestAmbientOcclusionGenerator.cpp @@ -67,7 +67,9 @@ void TestAmbientOcclusionGenerator::testExecute() // Calculate the ambient occlusion values IsVoxelTransparent isVoxelTransparent; - calculateAmbientOcclusion(&volData, &ambientOcclusionResult, volData.getEnclosingRegion(), 32.0f, 255, isVoxelTransparent); + QBENCHMARK { + calculateAmbientOcclusion(&volData, &ambientOcclusionResult, volData.getEnclosingRegion(), 32.0f, 255, isVoxelTransparent); + } //Check the results by sampling along a line though the centre of the volume. Because //of the two walls we added, samples in the middle are darker than those at the edge. diff --git a/tests/TestCubicSurfaceExtractor.cpp b/tests/TestCubicSurfaceExtractor.cpp index 0d806fe9..d03b74c4 100644 --- a/tests/TestCubicSurfaceExtractor.cpp +++ b/tests/TestCubicSurfaceExtractor.cpp @@ -154,7 +154,9 @@ void TestCubicSurfaceExtractor::testExecute() QCOMPARE(mesh.getNoOfIndices(), uExpectedIndices); QCOMPARE(mesh.getVertices()[uMaterialToCheck].getMaterial(), fNoMaterial);*/ - testForType(mesh); + QBENCHMARK { + testForType(mesh); + } QCOMPARE(mesh.getNoOfVertices(), uExpectedVertices); QCOMPARE(mesh.getNoOfIndices(), uExpectedIndices); QCOMPARE(mesh.getVertices()[uMaterialToCheck].getMaterial(), fExpectedMaterial); diff --git a/tests/TestLowPassFilter.cpp b/tests/TestLowPassFilter.cpp index 26238e63..4ace36eb 100644 --- a/tests/TestLowPassFilter.cpp +++ b/tests/TestLowPassFilter.cpp @@ -61,7 +61,9 @@ void TestLowPassFilter::testExecute() LowPassFilter< RawVolume, RawVolume, Density16 > lowPassfilter(&volData, reg, &resultVolume, reg, 5); //Test the normal implementation - lowPassfilter.execute(); + QBENCHMARK { + lowPassfilter.execute(); + } QCOMPARE(resultVolume.getVoxelAt(0,0,0), Density8(4)); QCOMPARE(resultVolume.getVoxelAt(1,1,1), Density8(21)); QCOMPARE(resultVolume.getVoxelAt(2,2,2), Density8(10)); diff --git a/tests/TestSurfaceExtractor.cpp b/tests/TestSurfaceExtractor.cpp index ea657394..4fad37bd 100644 --- a/tests/TestSurfaceExtractor.cpp +++ b/tests/TestSurfaceExtractor.cpp @@ -160,7 +160,9 @@ void TestSurfaceExtractor::testExecute() SurfaceMesh mesh; //Run the test for various voxel types. - testForType(mesh); + QBENCHMARK { + testForType(mesh); + } QCOMPARE(mesh.getNoOfVertices(), uExpectedVertices); QCOMPARE(mesh.getNoOfIndices(), uExpectedIndices); QCOMPARE(mesh.getVertices()[uMaterialToCheck].getMaterial(), fNoMaterial);