Helios++
Helios software for LiDAR simulations
|
A time watcher can be used to perform and report time measures. More...
#include <TimeWatcher.h>
Public Member Functions | |
TimeWatcher () | |
Instantiate a time watcher. | |
void | start () |
Start the time watcher, which sets the starting point for a time measure. More... | |
void | startIfNull () |
Start the time watcher but only if it has not been started before. Previous start might come either from TimeWatcher::start or from TimeWatcher::startIfNull. More... | |
void | releaseStart () |
Release stored start so it is null. More... | |
bool | hasStarted () const |
Check if time watcher has been started. More... | |
void | stop () |
Stop the time watcher, which sets the ending point for a time measure. | |
void | saveStart () |
Save the start time to local cache. More... | |
void | loadStart () |
Load the start time from local cache. More... | |
std::shared_ptr< std::chrono::high_resolution_clock::duration > | getElapsedTime () |
Obtain the elapsed time as the difference between the last start() and the last stop() invocations. More... | |
double | getElapsedDecimalSeconds () |
Obtain the elapsed time as the real number of seconds. More... | |
long | getElapsedSeconds () |
Obtain the elapsed time as the integer number of seconds. More... | |
long | getElapsedMillis () |
Obtain the elapsed time as the integer number of milliseconds. More... | |
long | getElapsedNanos () |
Obtain the elapsed time as the integer number of nanoseconds. More... | |
std::string | getElapsedFormat () |
Obtain the elapsed time as a string with format "HH:MM:SS". More... | |
void | reportSeconds (std::string msg="Total elapsed seconds: ") |
Report elapsed seconds through specified output stream. More... | |
void | reportMillis (std::string msg="Total elapsed milliseconds: ") |
Report elapsed seconds through specified output stream. More... | |
void | reportFormat (std::string msg="Total elapsed time: ") |
Report elapsed time through specified output stream using "HH:MM:SS" format. More... | |
void | synchronize (TimeWatcher const &source) |
Synchronizes start, end and saved start times with those of given source. More... | |
Private Member Functions | |
bool | hasNulls () |
Check if the time watcher has null start or end time points. More... | |
void | syncTimePoints (std::unique_ptr< std::chrono::high_resolution_clock::time_point > &p, std::unique_ptr< std::chrono::high_resolution_clock::time_point > const &q) |
Synchronize time point \(p\) with time point \(q\). More... | |
Private Attributes | |
std::unique_ptr< std::chrono::high_resolution_clock::time_point > | tStart |
Start time point. More... | |
std::unique_ptr< std::chrono::high_resolution_clock::time_point > | tEnd |
End time point. More... | |
std::unique_ptr< std::chrono::high_resolution_clock::time_point > | savedStart |
Used to store a temporary copy of current tStart. More... | |
A time watcher can be used to perform and report time measures.
double TimeWatcher::getElapsedDecimalSeconds | ( | ) |
Obtain the elapsed time as the real number of seconds.
std::string TimeWatcher::getElapsedFormat | ( | ) |
Obtain the elapsed time as a string with format "HH:MM:SS".
long TimeWatcher::getElapsedMillis | ( | ) |
Obtain the elapsed time as the integer number of milliseconds.
long TimeWatcher::getElapsedNanos | ( | ) |
Obtain the elapsed time as the integer number of nanoseconds.
long TimeWatcher::getElapsedSeconds | ( | ) |
Obtain the elapsed time as the integer number of seconds.
std::shared_ptr< std::chrono::high_resolution_clock::duration > TimeWatcher::getElapsedTime | ( | ) |
Obtain the elapsed time as the difference between the last start() and the last stop() invocations.
|
private |
Check if the time watcher has null start or end time points.
bool TimeWatcher::hasStarted | ( | ) | const |
Check if time watcher has been started.
void TimeWatcher::loadStart | ( | ) |
Load the start time from local cache.
void TimeWatcher::releaseStart | ( | ) |
Release stored start so it is null.
For instance, following piece of code will only set the start time at first TimeWatcher::startIfNull call
However, following piece of code will set the start time at second TimeWatcher::startIfNull too
void TimeWatcher::reportFormat | ( | std::string | msg = "Total elapsed time: " | ) |
Report elapsed time through specified output stream using "HH:MM:SS" format.
msg | Message to be shown by the report. By default "Total elapsed time: " |
void TimeWatcher::reportMillis | ( | std::string | msg = "Total elapsed milliseconds: " | ) |
Report elapsed seconds through specified output stream.
msg | Message to be shown by the report. By default "Total elapsed millisecconds: " |
void TimeWatcher::reportSeconds | ( | std::string | msg = "Total elapsed seconds: " | ) |
Report elapsed seconds through specified output stream.
msg | Message to be shown by the report. By default "Total elapsed seconds: " |
void TimeWatcher::saveStart | ( | ) |
Save the start time to local cache.
void TimeWatcher::start | ( | ) |
Start the time watcher, which sets the starting point for a time measure.
void TimeWatcher::startIfNull | ( | ) |
Start the time watcher but only if it has not been started before. Previous start might come either from TimeWatcher::start or from TimeWatcher::startIfNull.
void TimeWatcher::synchronize | ( | TimeWatcher const & | source | ) |
Synchronizes start, end and saved start times with those of given source.
source | Time watcher to be synchronized with |
|
private |
Synchronize time point \(p\) with time point \(q\).
p | Time point to be synchronized |
q | Time point to synchronize with |
|
private |
Used to store a temporary copy of current tStart.
|
private |
End time point.
|
private |
Start time point.