This timer class is used for determining how long a set of processes run for, to the precision of milliseconds. This can be useful if you want to benchmark PCs or want to know whether changing some code in your application affects the speed at which it processes.
I created this class because I could not find another class or set of functions which could time how long it took for my applications to run. After creating the initial object class for the timer, I then expanded on it to create the class which I am describing now.
Using the code
The interface consists of one object:
timer. In order to use this class, you need to create an instance of the object using either the default constructor or the boolean constrictor.
To create a timer instance, use one of the following statements:
You can start, stop, and restart the timer by using the following statements:
To reset the accumulated time:
You can output the running length of the timer directly using "
<<" or store the object as a
std::cout << newTimerInstance;
std::string newString = newTimerInstance;
int newInt = newTimerInstance;
double newDouble = newTimerInstance;
For more information on how to use the class, see the example.cpp included with the package.
- Timer class 1.1 - API modified to represent more closely to a traditional timer. The
Restart method has been replaced with
Reset. MS naming conventions for objects now used.
- Timer class 1.2 - API redesigned, hopefully making the usage easier.
Resume methods have been added, and the functionality of the
Stop methods have been modified. This makes the timer concept more intuitive.
For more information, visit: www.summatix.com.