I am working on a little game engine. All major features are implemented yet, despite game logic which I assume not to be such a computational effort. The framerate is at least around 40 FPS, most of the time above 60 FPS.

I would like to speed up my engine now. There are several performance heavy tasks, like physics simulation and collision detection where I use Bullet Physics for, geometry drawing and texturing, deferred lighting, post effects like SSAO. Later on maybe character animation and artificial intelligence may add up.

How to find the bottleneck in such a typical OpenGL game? I am not familiar with profilers, and I have no idea how to use them, especially with asynchronous code like Bullet Physics.


Profiling (and adjusting code where necessary). There's different profiling software available (your compiler might provide built-in hooks for this or bring the tools like GCC and MSVC do) that won't require you to actually edit or modify your code just to take measurements.

The easiest - and most generic way to do it (which will require modifications of your codebase) - would be adding several measurements on your own, e.g. track how long it takes to render backgrounds, track how long it takes to render objects, track how long it takes to process shaders, etc.

For example, this page shows you some example screenshots on how this is presented when using the Unreal Engine 3. You don't need any fancy things for this, you don't even have to print it on screen (just log it somewhere).

One important thing to note: If you're running Windows, make sure you don't write anything to the console window; or at least try not to flush the output too often (e.g. by using std::endl). This can slow you down quite a bit compared to any real work being done.

  • 3
    \$\begingroup\$ I'd remove the "maybe" in "Maybe some profiling software". Profiller will do exactly what are you suggesting in the second paragraph. It will just do it for every method/function/procedure. \$\endgroup\$ Jun 7 '13 at 10:25
  • \$\begingroup\$ For profiling software, I would suggest SlimTune. Worked for me and it is open source. \$\endgroup\$
    – jgallant
    Jun 7 '13 at 10:47
  • \$\begingroup\$ Intended it to be "you could use", but will just reword it. ;) \$\endgroup\$
    – Mario
    Jun 7 '13 at 10:49
  • \$\begingroup\$ How to profile asynchronous tasks like Bullet Physics? I guess if there are are two tasks running on the same core, the bottleneck one will slow down both. How to detect which one is the actual reason? And how to profile OpenGL shaders? I heard that OpenGL calls in C++ code just add tasks to a quene of the video card and may return before the draw call actually is performed. \$\endgroup\$
    – danijar
    Jun 7 '13 at 11:22
  • \$\begingroup\$ If you'd just change the first word from Debugging to Profiling I'd vote you up :-) You start with the wrong word and then say mostly the right thing - Profiling is the only way to optimize \$\endgroup\$ Jun 7 '13 at 11:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.