390 9. Tools for Debugging and Development
{
PROFILE("Poll Joypad");
PollJoypad();
}
{
PROFILE("Game Object Update");
UpdateGameObjects();
}
{
PROFILE("Animation");
UpdateAllAnimations();
}
{
PROFILE("Joint Post-Processing");
PostProcessJoints();
}
{
PROFILE("Collision");
DetectCollisions();
}
{
PROFILE("Physics");
RunPhysics();
}
{
PROFILE("Animation Finaling");
GenerateFinalAnimationPoses();
}
{
PROFILE("Cameras");
UpdateCameras();
}
{
PROFILE("Rendering");
RenderScene();
}
{
PROFILE("Audio");
UpdateAudio();
}
}
The PROFILE() macro shown above would probably be implemented as a
class whose constructor starts the timer and whose destructor stops the timer
and records the execution time under the given name. Thus it only times the
code within its containing block, by nature of the way C++ automatically con-
structs and destroys objects as they go in and out of scope.