Adding Vector performance test.
This commit is contained in:
parent
40a290bfce
commit
a9f1a29868
@ -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)
|
||||
|
@ -34,6 +34,7 @@ class TestVector: public QObject
|
||||
void testLength();
|
||||
void testDotProduct();
|
||||
void testEquality();
|
||||
void testPerformance();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user