Performance analysis (
Edit: All based on http://linus.saydoo.com/mGameTask.html of course), here we go.
First of all,
Code: Select all
PROFILER_BEGINSECTION(7);
Tile();
PROFILER_ENDSECTION(7);
Tile() is the most "expensive" function. No surprise here (I guess it does the whole screen/background painting). This alone limits the whole loop framerate to 20FPS (1s / 50ms).
Now I haven't played the game, but I guess the loop is inclusive menu and level selection and so on, and the actual "currently the game is being played" is between the ******************s? If so, then we've got 586 frames of real gameplay captured.
First of all one can notice the sections whichwere never executed. Optimizing here is pointless -- at least for this testcase muntoo provided...
The next thing is that EMYMoveLeft(E) + EMYMoveRight(E) + EMYMoveDown(E) took alone ~9ms, and EMYMoveUp was never executed.
The last two sections are obviously expensive too, but they're not inside the inner play-game loop.
One "cool" thing is this:
Code: Select all
PROFILER_BEGINSECTION(11);
if (E.eat != 8)
EMYMoveDown(E);
PROFILER_ENDSECTION(11);
The HTML's "time per call" says:
> 2.8 ms (in 94%)
< 1.0 ms (in 5%)
This tells us, that in 5% of the calls, this section was executed really quickly. In this case it probably means that
(E.eat == 8)
was true 5% of the cases (could be useful to make estimates where to optimize).
You can see, I clearly didn't place the sections optimally. The % estimates of total profiled time (28% for the Tile() call) are now "mixed" with the whole big outer loop, and the inner
(play == 1)
section...
Also I should've placed much more sections, but I couldn't be bothered (and didn't know how much memory was available). One could go ahead and place the sections "where they make sense" now. Maybe just one big section inside the
(play == 1)
part. That way one has an estimate how fast this part is, and can compare after modifactions.
A missing feature is nested profiler sections, I know. They would come in really handy. I think the NXC code of my profiler supports this, but the Python parser doesn't (just because of me being lazy and because I didn't really know how to fit it into the current HTML layout).
Anyway, John & spiller, if you want to do your performance tests with the profiler, you're very welcome. Parsing the .prf file is really easy, you just need Python installed and a command line. I'm happy to analyze files and upload HTML versions when anybody sends my matching pairs of .nxc and .prf files.
And since I'm happy now, I won't bother you anymore with "please test the profiler". Thanks.