Good idea Egon.
You can download source here:
http://games.martineriksen.net/PerformanceTest.zip
In the “bin” folder there is the APK which you can install using adb install. Then you can run the test by starting the PerformanceTest app on your phone. The test will output the data in LogCat - these are the interesting lines (seen on a Nexus One 2.1):
06-03 14:56:01.445: INFO/System.out(22956): time: 247.8s >> vertex buffer single puts
06-03 14:56:01.445: INFO/System.out(22956): time: 254.2s >> vertex buffer single puts with specified positions
06-03 14:56:01.445: INFO/System.out(22956): time: 264.3s >> vertex buffer full array puts
06-03 14:56:01.445: INFO/System.out(22956): time: 0.3s >> vertex buffer wrapping
06-03 14:56:01.445: INFO/System.out(22956): time: 285.3s >> wrapped array to vertex buffer
Here is the interesting code that runs this part of the test:
FloatBuffer nativeDirectFloatBuffer = OpenGlMemoryUtil.makeFloatBuffer(FLOAT_BUFFER_SIZE);
float[] floatArray = new float[FLOAT_BUFFER_SIZE];
for (int i = 0; i < FLOAT_BUFFER_SIZE; i++) {
floatArray[i]=0.5f;
}
time = print("Going VertexBuffers");
for (int i = 0; i < TESTSIZE_MILLIONTH; i++) {
nativeDirectFloatBuffer.position(0);
for (int k = 0; k < FLOAT_BUFFER_SIZE; k++) {
nativeDirectFloatBuffer.put(0.5f);
}
}
time = PerfLogUtil.logTime(time, "vertex buffer single puts", logindex++, TESTSIZE_THOUSANDS);
time = print("Going VertexBuffers");
for (int i = 0; i < TESTSIZE_MILLIONTH; i++) {
for (int k = 0; k < FLOAT_BUFFER_SIZE; k++) {
nativeDirectFloatBuffer.put(k,0.5f);
}
}
time = PerfLogUtil.logTime(time, "vertex buffer single puts with specified positions", logindex++, TESTSIZE_THOUSANDS);
time = print("Going VertexBuffers");
for (int i = 0; i < TESTSIZE_MILLIONTH; i++) {
for (int k = 0; k < FLOAT_BUFFER_SIZE; k++) {
floatArray[k]=.5f;
}
nativeDirectFloatBuffer.position(0);
nativeDirectFloatBuffer.put(floatArray);
}
time = PerfLogUtil.logTime(time, "vertex buffer full array puts", logindex++, TESTSIZE_THOUSANDS);
FloatBuffer floatBufferWrappedArray = FloatBuffer.wrap(floatArray);
time = PerfLogUtil.checkPoint();
for (int i = 0; i < TESTSIZE_MILLIONTH; i++) {
floatBufferWrappedArray = FloatBuffer.wrap(floatArray);
}
time = PerfLogUtil.logTime(time, "vertex buffer wrapping", logindex++, TESTSIZE_THOUSANDS);
for (int i = 0; i < TESTSIZE_MILLIONTH; i++) {
for (int k = 0; k < FLOAT_BUFFER_SIZE; k++) {
floatArray[k]=.5f;
}
nativeDirectFloatBuffer.position(0);
floatBufferWrappedArray.position(0);
nativeDirectFloatBuffer.put(floatBufferWrappedArray);
}
time = PerfLogUtil.logTime(time, "wrapped array to vertex buffer", logindex++, TESTSIZE_THOUSANDS);