Realizes a stopwatch for measuring elapsed time. More...
#include <ogdf/basic/Stopwatch.h>
Public Member Functions | |
Stopwatch () | |
Initializes a stop watch with total time 0. More... | |
Stopwatch (int64_t milliSecs) | |
Initializes a stopwatch and sets its total time to milliSecs . More... | |
virtual | ~Stopwatch () |
void | addCentiSeconds (int64_t centiSeconds) |
Adds centiSeconds to total time. More... | |
int64_t | centiSeconds () const |
Returns the currently elapsed time in 1/100-seconds. More... | |
bool | exceeds (int64_t maxSeconds) const |
Returns true iff the currently elapsed time exceeds maxSeconds . More... | |
int64_t | hours () const |
Returns the currently elapsed time in hours. More... | |
int64_t | milliSeconds () const |
Returns the currently elapsed time in milliseconds. More... | |
int64_t | minutes () const |
Returns the currently elapsed time in minutes. More... | |
void | reset () |
Stops the stopwatch and sets its total time to 0. More... | |
bool | running () const |
Returns true if the stopwatch is running, false otherwise. More... | |
int64_t | seconds () const |
Returns the currently elapsed time in seconds. More... | |
void | start (bool reset=false) |
Starts the stopwatch. More... | |
void | stop () |
Stops the stopwatch and adds the difference between the current time and the starting time to the total time. More... | |
Protected Member Functions | |
virtual int64_t | theTime () const =0 |
Returns the current time in milliseconds (from some fixed starting point). More... | |
Private Attributes | |
bool | m_running |
true, if the timer is running. More... | |
int64_t | m_startTime |
The start time of the timer in milliseconds. More... | |
int64_t | m_totalTime |
The total time in milliseconds. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const Stopwatch &stopwatch) |
Writes the currently elapsed time in the format hh:mm:ss.sec/100 to output stream os . More... | |
Realizes a stopwatch for measuring elapsed time.
Definition at line 45 of file Stopwatch.h.
|
inline |
Initializes a stop watch with total time 0.
After creation the stopwatch is not running, i.e., it has to be started explicitly for measuring time.
Definition at line 56 of file Stopwatch.h.
|
inlineexplicit |
Initializes a stopwatch and sets its total time to milliSecs
.
After creation the stopwatch is not running, i.e., it has to be started explicitly for measuring time.
milliSecs | The intial value of the total time in milliseconds. |
Definition at line 65 of file Stopwatch.h.
|
inlinevirtual |
Definition at line 68 of file Stopwatch.h.
|
inline |
Adds centiSeconds
to total time.
centiSeconds | The number of centiseconds to be added. |
Definition at line 135 of file Stopwatch.h.
|
inline |
Returns the currently elapsed time in 1/100-seconds.
It is not necessary to stop the timer to get the correct time.
Definition at line 105 of file Stopwatch.h.
|
inline |
Returns true iff the currently elapsed time exceeds maxSeconds
.
Definition at line 129 of file Stopwatch.h.
|
inline |
Returns the currently elapsed time in hours.
It is not necessary to stop the timer to get the correct time. The result is rounded down to the next integer value.
Definition at line 126 of file Stopwatch.h.
|
inline |
Returns the currently elapsed time in milliseconds.
It is not necessary to stop the timer to get the correct time.
Definition at line 97 of file Stopwatch.h.
|
inline |
Returns the currently elapsed time in minutes.
It is not necessary to stop the timer to get the correct time. The result is rounded down to the next integer value.
Definition at line 119 of file Stopwatch.h.
|
inline |
Stops the stopwatch and sets its total time to 0.
Definition at line 85 of file Stopwatch.h.
|
inline |
Returns true if the stopwatch is running, false otherwise.
Definition at line 91 of file Stopwatch.h.
|
inline |
Returns the currently elapsed time in seconds.
It is not necessary to stop the timer to get the correct time. The result is rounded down to the next integer value.
Definition at line 112 of file Stopwatch.h.
void ogdf::Stopwatch::start | ( | bool | reset = false | ) |
Starts the stopwatch.
For safety reasons starting a running timer is an error.
reset | If this flag is set to true, the stopwatch is reset before it is started. |
void ogdf::Stopwatch::stop | ( | ) |
Stops the stopwatch and adds the difference between the current time and the starting time to the total time.
Stopping a non-running stopwatch is an error.
|
protectedpure virtual |
Returns the current time in milliseconds (from some fixed starting point).
This pure virtual function is used for measuring time differences. It must be implemented in derived classes.
Implemented in ogdf::StopwatchWallClock, and ogdf::StopwatchCPU.
|
friend |
Writes the currently elapsed time in the format hh:mm:ss.sec/100
to output stream os
.
os | The output stream. |
stopwatch | The stopwatch whose elapsed time shall be written. |
os
.
|
private |
true, if the timer is running.
Definition at line 48 of file Stopwatch.h.
|
private |
The start time of the timer in milliseconds.
Definition at line 46 of file Stopwatch.h.
|
private |
The total time in milliseconds.
Definition at line 47 of file Stopwatch.h.