Skip to content

Instantly share code, notes, and snippets.

@realazthat
Created April 18, 2012 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save realazthat/2415094 to your computer and use it in GitHub Desktop.
Save realazthat/2415094 to your computer and use it in GitHub Desktop.
cpu timer
struct cputimer
{
cputimer(const std::string& name)
: name(name)
{
}
~cputimer()
{
printf("Timed \"%s\" at %d ms", name.c_str(), timer.getMilliseconds());
}
std::string name;
Ogre::Timer timer;
};
///Usage:
int mysuspect_function()
{
cputimer mysuspect_function_timer("mysuspect_function");
for ( ... )
{
cputimer mysuspect_operation_timer("test time of scope");
///Do something here
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment