Game Design, Programming and running a one-man games business…

Handy optimising tip

If you have a profiler like aqtime that can be remotely enabled and disabled try this.

  1. Have a flag that is ‘bprofileframe’ and set it to false by default
  2. Bind a keystroke to a function that toggles the flag on
  3. In your render loop, before rendering, if the flag is true, enable debugging
  4. At the end of the render loop, if the flag is true, set false, and disable debugging.

Voila! you have a keystroke that will capture a single frames profiling data and ONLY that frame, making for really easy profiling on very specific situations. Works a treat. Now I just need to work out how to make it all faster :D


6 thoughts on Handy optimising tip

  1. Of course, if you’re capturing a single frame event you probably want a keystroke to slow the whole game down as well so you can more accurately determine what frame you need.

  2. Optimizing is fun, but only with a profiler. Alas I’m not aware of a way to turn gprof on/off, so I just leave it on a particular scene for a long time, to try and out-weigh the loading/menus/etc. up until that point. Not as lovely as this, but it works.

  3. I usually do what PsySal does, so I can find out “on average” what is taking longest for a particular scenario. Of course, that doesn’t help if it’s only slow when a particular tank’s firing animation happens – then a 1-frame capture would be useful.

    Wait, did I say “tank”?

  4. Way-back-when, I worked on an embedded arcade emulator system and I used a similar tactic — though I would capture ‘n’ frames into a buffer and then dump out the data (in a CSV file) so that it could be analyzed — each step of the emulation (cpu, graphics, sound, housekeeping, IO) got its own column in the output file.

    The other piece that was VERY handy was a repeatable random number generator (fixed/user provided seed) and an input record/replay system.If we had a place where a slowdown happened, we could defer the performance recording for a specific # of frames and then start recording. Of course, we had a fixed frame rate of 60HZ, which made input very deterministic.

    Love GSB, looking forward to the next thing :-)
    –pryankster

  5. Well I thought it was hilarious that the telegraph is aghast at a mere 30% rise over 20 years. At the current rate of 16% rises a year, mid recession and with some north sea oil and gas still coming in… I think 30% in 3 years at most.

Comments are currently closed.