Search code examples
iosxcodeperformancexcode4instruments

How to measure and compare performance for two different implementations?


I have two different algorithms and want to know which one performs better in OpenGL ES.

There's this Time Profiler tool in Instruments which tells me how much % which line of code consumes of the overall processing time, but this is always relative to this algorithm.

How can I get an absolute value so I could compare which algorithm performs better? Actually I just need a percentage of overall CPU occupation. Couldn't find it in Time Profiler. Just percentages of consumed time but not overall CPU workload.

There was also a WWDC show talking about some nifty CPU tracker which showed each core separately. Which performance instrument do I need and at which values must I look for this comparison?


Solution

  • The situation you're talking about, optimizing OpenGL ES performance, is something that Time Profiler isn't well suited to help you with. Time Profiler simply measures CPU-side time spent in various functions and methods, not the actual load something places on the GPU when rendering. Also, the deferred nature of the iOS GPUs means that processing for draw calls can actually take place much later than you'd expect, causing certain functions to look like bottlenecks when they aren't. They just happen to be when actions queued up by earlier calls are finally executed.

    As a suggestion, don't measure in frames per second, but instead report the time in milliseconds it takes from the start of your frame rendering to just after a glFinish() or -presentRenderbuffer: call. When you're profiling, you want to work directly with the time it takes to render, because it's easier to understand the impact you're having on that number than on its inverse, frames per second. Also, as you've found, iOS caps its display framerate at 60 FPS, but you can measure rendering times well below 16.7 ms to tell the difference between your two fast approaches.

    In addition to time-based measurements, look at the Tiler and Renderer Utilization statistics in the OpenGL ES Driver instrument to see the load you are placing on the vertex and fragment processing portions of the GPU. When combined with the overall CPU load of your application while rendering, this can give a reasonable representation of the efficiency of one approach vs. another.