Open-source OpenGL profiler for Linux [closed] Open-source OpenGL profiler for Linux [closed] linux linux

Open-source OpenGL profiler for Linux [closed]


Thanks to @cypheon's answer, I checked out BuGLe. It is fantastic, but I had to spend a bit of time getting useful profiling output. I wanted to add this as a comment on that answer, but I really need to paste full code examples so I started a new answer.

As he suggested, the stats_calltimes filter is good for profiling -- not ideal (since it doesn't show call stack information), but with a bit of work, it can show you the total flat time for each GL function per frame.

You need to edit both the ~/.bugle/filters and ~/.bugle/statistics files. Firstly, add this chain to the end of filters:

chain showcalltimes{    filterset stats_calls    filterset stats_calltimes    filterset showstats    {        show "average time per call"    }}

Now run your program with the command:

BUGLE_CHAIN=showcalltimes LD_PRELOAD=libbugle.so <your-program>

This will print the average time spent in each GL function per frame. That isn't terribly useful by itself, because for a call like glVertex, called thousands of times per frame, it will probably show up as 0.00ms even though the cumulative time is quite significant. So add a new entry to statistics:

"total time per call" = d("calls:*") / d("calls:*") * d("calltimes:*") / d("frames") * 1000{    precision 3    label "* (ms)"}

I used the same trick as the "calls per frame" statistic: multiply and divide by d("calls:*") to cause a divide-by-zero error for any function that was never called, to avoid showing 0.00 for all of the irrelevant functions.

Now, go back to the showcalltimes chain we added to filters, and change "average time per call" to "total time per call":

chain showcalltimes{    filterset stats_calls    filterset stats_calltimes    filterset showstats    {        show "total time per call"        #key_accumulate "A"        #key_noaccumulate "I"    }}

And now we will see the useful stat of the total time spent in each function, per frame. If you want to average these stats out over many frames, uncomment the key_accumulate lines above, and then you can hit "A" (or remap it to a key of your choice) to start accumulating. Over time, you will see the statistics stop bouncing around so much as they average out over many frames.

You can also log these statistics to an output file with this chain:

chain logcalltimes{    filterset stats_calls    filterset stats_calltimes    filterset log    {        filename "bugle.log"    }    filterset logstats    {        show "total time per call"    }}

This is pretty hard to read, since it simply puts the individual stats for each frame one after the other, and I haven't found a way to average them over time. So my preferred method for reading statistics is the showcalltimes chain with the accumulator turned on.


Have a look at BuGLe. Its main target is not profiling, but it has a filter, which shows the time spent in each OpenGL call.


I would really recommend this small profiler:http://silverspaceship.com/src/iprof/, it is not bound to profiling opengl, but does so very well! Also it can use opengl to display the profiling stats, which means it is very portable.