Another useful technique is ``profiling,'' to find out where your program is spending most of its time. This can help you to make a program more efficient.
Here is how to profile a program:
rm src/*.o bin/circle
Makefile, and change the
PROFILE = -p
shutdowncommand when you have run long enough to get a good profiling base under normal usage conditions. If you crash the game, or kill the process externally, you won't get profiling information.
prof bin/circle > prof.out
man prof'' to understand the format of the output.
For advanced profiling, you can use ``
PROFILE = -pg'' in step 2,
and use the
``gprof'' command in step 5. The ``gprof'' form of profiling gives
you a report
which lists exactly how many times any function calls any other function. This
information is valuable for debugging as well as performance analysis.
Availability of ``prof'' and ``gprof'' varies from system to system. Almost every Unix system has ``prof''. Only some systems have ``gprof''.