diff --git a/tests/TestArray.cpp b/tests/TestArray.cpp index bc3f8644..8dde377a 100644 --- a/tests/TestArray.cpp +++ b/tests/TestArray.cpp @@ -29,6 +29,52 @@ freely, subject to the following restrictions: using namespace PolyVox; +void TestArray::testCArraySpeed() +{ + const int width = 128; + const int height = 128; + + int cArray[width][height]; + + QBENCHMARK + { + int ct = 1; + int expectedTotal = 0; + for (int y = 0; y < height; y++) + { + for (int x = 0; x < width; x++) + { + cArray[x][y] = ct; + expectedTotal += cArray[x][y]; + ct++; + } + } + } +} + +void TestArray::testPolyVoxArraySpeed() +{ + const int width = 128; + const int height = 128; + + Array<2, int> polyvoxArray(ArraySizes(width)(height)); + + QBENCHMARK + { + int ct = 1; + int expectedTotal = 0; + for (int y = 0; y < height; y++) + { + for (int x = 0; x < width; x++) + { + polyvoxArray[x][y] = ct; + expectedTotal += polyvoxArray[x][y]; + ct++; + } + } + } +} + void TestArray::testReadWrite() { int width = 5; diff --git a/tests/TestArray.h b/tests/TestArray.h index fe935511..2d3e5951 100644 --- a/tests/TestArray.h +++ b/tests/TestArray.h @@ -31,6 +31,8 @@ class TestArray: public QObject Q_OBJECT private slots: + void testCArraySpeed(); + void testPolyVoxArraySpeed(); void testReadWrite(); };