Created
April 18, 2012 17:08
-
-
Save realazthat/2415094 to your computer and use it in GitHub Desktop.
cpu timer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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