A timer that keeps track of time, prints formatted time, checks if an interval has passed etc.
More...
#include <Timer.hpp>
|
static string | prettyTime (float secondsFloat) |
| Formats seconds as HH:MM:SS.mmm. More...
|
|
|
using | myClock = chrono::high_resolution_clock |
|
|
static int | numDigits (int32_t x) |
| Counts the number of digits in an integer. More...
|
|
static int | numDigits (char n) |
| Counts the number of digits in a char. More...
|
|
static string | zeroPad (int value, unsigned int desiredSize) |
| Pads a number with 0s on the left until it reaches a desired length. More...
|
|
A timer that keeps track of time, prints formatted time, checks if an interval has passed etc.
Definition at line 18 of file Timer.hpp.
◆ myClock
◆ Timer()
Timer::Timer |
( |
unsigned int |
interval = 0 , |
|
|
unsigned int |
predictedIters = 0 |
|
) |
| |
|
inlineexplicit |
Creates an instance of a timer object.
- Parameters
-
interval | the interval the timer will check for |
predictedIters | number of predicted iterations, so th etime can output a predicted time of conclusion |
Definition at line 93 of file Timer.hpp.
◆ activate()
bool Timer::activate |
( |
unsigned int |
currentIter = 0 | ) |
|
|
inline |
Checks if the time interval passed in the constructor has passed.
- Parameters
-
currentIter | current iteration number, so an estimated conclusion time can be printed |
- Returns
- true if the stipulated interval has passed, otherwise false
Definition at line 110 of file Timer.hpp.
◆ numDigits() [1/2]
static int Timer::numDigits |
( |
int32_t |
x | ) |
|
|
inlinestaticprivate |
Counts the number of digits in an integer.
- Parameters
-
- Returns
- number of digits in
x
Definition at line 30 of file Timer.hpp.
◆ numDigits() [2/2]
static int Timer::numDigits |
( |
char |
n | ) |
|
|
inlinestaticprivate |
Counts the number of digits in a char.
- Parameters
-
- Returns
- number of digits in
n
Definition at line 65 of file Timer.hpp.
◆ prettyTime()
static string Timer::prettyTime |
( |
float |
secondsFloat | ) |
|
|
inlinestatic |
Formats seconds as HH:MM:SS.mmm.
- Parameters
-
secondsFloat | number of seconds |
- Returns
- a string separating the given seconds into hours, minutes, seconds and milliseconds
Definition at line 134 of file Timer.hpp.
◆ runningTime()
string Timer::runningTime |
( |
| ) |
|
|
inline |
- Returns
- the time since the timer has been activated
Definition at line 149 of file Timer.hpp.
◆ start()
◆ zeroPad()
static string Timer::zeroPad |
( |
int |
value, |
|
|
unsigned int |
desiredSize |
|
) |
| |
|
inlinestaticprivate |
Pads a number with 0s on the left until it reaches a desired length.
- Parameters
-
value | the integer value to be zero-padded |
desiredSize | the desired size of the padded representation |
- Returns
- a string with
value
zero-padded to desiredSize
size
Definition at line 83 of file Timer.hpp.
◆ interval
unsigned int Timer::interval |
|
private |
◆ lastUpdate
◆ predictedIters
unsigned int Timer::predictedIters |
|
private |
◆ startTime
chrono::time_point<chrono::system_clock> Timer::startTime |
|
private |
The documentation for this class was generated from the following file: