|
ug4
|
Stopwatch class for quickly taking times. More...
#include <stopwatch.h>
Public Member Functions | |
| double | ms () |
| Returns milliseconds since call of start. | |
| void | start () |
| Starts the Stopwatch. | |
| void | stop () |
| Stops the Stopwatch. | |
| Stopwatch () | |
| Default constructor for the Stopwatch. | |
Private Attributes | |
| std::chrono::high_resolution_clock::time_point | begin |
| Time point of the start of Stopwatch. | |
| bool | bRunning |
| Flag indicating state of Stopwatch. | |
| std::chrono::high_resolution_clock::time_point | end |
Number of microseconds since begin. | |
Friends | |
| std::ostream & | operator<< (std::ostream &out, Stopwatch &s) |
| Prints number of milliseconds since call of start() to ostream. | |
Stopwatch class for quickly taking times.
Depending on CXX11 flag, two different versions are compiled. If CXX11=ON, std::chrono from C++11's STL is used providing high resolution (microseconds) time measuring. Otherwise std::ctime is used providing millisecond resolution.
CXX11=OFF timings shorter than 100ms seem to be rather inaccurate.
|
inline |
Default constructor for the Stopwatch.
References begin, bRunning, end, and ug::get_clock_s().
|
inline |
Returns milliseconds since call of start.
Returns the amount of milliseconds passed between calls of Stopwatch::start() and Stopwatch::stop() or this function call.
CXX11=ON returned milliseconds have microsecond resolution.References begin, bRunning, end, and ug::get_clock_s().
|
inline |
Starts the Stopwatch.
References begin, bRunning, and ug::get_clock_s().
|
inline |
Stops the Stopwatch.
References bRunning, end, and ug::get_clock_s().
|
friend |
Prints number of milliseconds since call of start() to ostream.
Pretty prints the amount of milliseconds passed between calls of Stopwatch::start() and Stopwatch::stop() or this function call to the specified std::ostream.
| [out] | out | std::ostream to print number of milliseconds to |
| [in] | sw | a Stopwatch instance (usualy 'this') |
|
private |
Time point of the start of Stopwatch.
Referenced by ms(), start(), and Stopwatch().
|
private |
|
private |
Number of microseconds since begin.
Referenced by ms(), stop(), and Stopwatch().