Adding Vector performance test.

This commit is contained in:
David Williams 2014-09-05 16:06:40 +02:00
parent 40a290bfce
commit a9f1a29868
2 changed files with 23 additions and 0 deletions

View File

@ -29,6 +29,12 @@ freely, subject to the following restrictions:
using namespace PolyVox;
Vector3DFloat incrementVector(Vector3DFloat input)
{
Vector3DFloat result = input += 1.0f;
return result;
}
void TestVector::testLength()
{
Vector3DInt8 vec(3, 4, 5);
@ -51,4 +57,20 @@ void TestVector::testEquality()
QCOMPARE(vecxy != vecz, true);
}
void TestVector::testPerformance()
{
Vector3DFloat vec(1.0, 1.0, 1.0);
QBENCHMARK
{
for(uint32_t ct = 0; ct < 10000000; ct++)
{
vec = incrementVector(vec);
}
}
// Use the result so the calls don't get optimized away.
QCOMPARE(vec.lengthSquared() > 0.0f, true);
}
QTEST_MAIN(TestVector)

View File

@ -34,6 +34,7 @@ class TestVector: public QObject
void testLength();
void testDotProduct();
void testEquality();
void testPerformance();
};
#endif