It seems the PolyVox Array class is really slow compared to raw C arrays. I've added a test ready for some experimentation.

This commit is contained in:
David Williams 2014-08-21 16:57:23 +02:00
parent d0aa7cd60f
commit d9f328cadb
2 changed files with 48 additions and 0 deletions

View File

@ -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;

View File

@ -31,6 +31,8 @@ class TestArray: public QObject
Q_OBJECT
private slots:
void testCArraySpeed();
void testPolyVoxArraySpeed();
void testReadWrite();
};