Reigertje
Reigertje

Reputation: 735

Measure Render Time OpenGL ES 2.0

I want to measure render performance on various Android devices using OpenGL ES 2.0. I do this by drawing a (textured) quad the size of the screen and drawing it N times. The basic idea looks like this:

start = System.currentTimeMillis();
for (int i = 0; i < N; ++i) {
  GLES20.glDrawArrays(GLES20.GL_TRIANGLE_FAN, 0, v_n);
}
GLES20.glFinish();
time = System.currentTimeMillis()-start;

In reality I store the values and measure the average over a certain amount of render passes, but that is not the problem. This approach appeared to go well with my device (Samsung Galaxy SIII) and the HTC Legend. However, the Samsung Galaxy S seems to ignore the glFinish() resulting in a pretty intense (but false) render speed. I have read before that some devices don't really listen to glFinish(), but if not like this, how can I measure the render speed?

I have also tried the other way I have seen all over the internet (mainly in the context of measuring FPS):

@Override
public void onDrawFrame(GL10 unused) {
  time =  System.currentTimeMillis()-start;
  //store time somewhere
  start = System.currentTimeMillis();
  ...
  //rendering here
  ...
}

Here you measure the time at the beginning of the next call to onDrawFrame(..) with the idea that it would not be called unless the previous rendering has completed. But this results in the same problem.

Is there another way? Or should I just avoid these devices for performance measurements?

Upvotes: 0

Views: 3137

Answers (2)

Karthik H
Karthik H

Reputation: 123

You can also use apps like GameBench that work on any android device and will measure the FPS. It also retrieves GPU Usage for devices that use Adreno and IMG GPUs. The app also collects screenshots so you can understand what was happening when frame rate drops.

Upvotes: 0

Joe Davis
Joe Davis

Reputation: 198

Measuring GPU performance can be tricky. There are a number of things you have to consider, such as how a graphics driver will interpret a glFlush/glFinish and how VSync will effect results.

Calling glFinish() per-frame will never give a true representation of performance on GPUs that defer work - such as PowerVR - as the architecture relies on processing multiple frames in parallel to achieve optimal performance. On devices where the glFinish() call is honoured (i.e. the CPU thread blocks until the GPU render is complete), your test will cause the render to be serialized which will incur a significant performance hit. Also, blocking the CPU thread until GPU work completes will introduce another large overhead.

When Vsync is enabled, you'll also be measuring time the GPU is waiting for the flip to occur. If possible, you should disable Vsync when running performance tests like this or render offscreen (i.e. to FBOs) so you can avoid the vsync limit. Alternatively you can use GPU profiling tools, such as Imagination's PVRTune, to obtain accurate timing information for the GPU time spent processing your render.

The "Micro-benchmark your render on PowerVR Series5, Series5XT and Series6 GPUs" post on the Imagination blog explains best practices for writing performance tests like this.

Upvotes: 6

Related Questions