Helios++
Helios software for LiDAR simulations
TimeWatcher Class Reference

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.
 
void stop ()
 Stop the time watcher, which sets the ending point for a time measure.
 
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...
 

Private Member Functions

bool hasNulls ()
 Check if the time watcher has null start or end time points. 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...
 

Detailed Description

A time watcher can be used to perform and report time measures.

Author
Alberto M. Esmoris Pena
Version
1.0

Member Function Documentation

◆ getElapsedDecimalSeconds()

double TimeWatcher::getElapsedDecimalSeconds ( )

Obtain the elapsed time as the real number of seconds.

Returns
Elapsed time in real seconds

◆ getElapsedFormat()

std::string TimeWatcher::getElapsedFormat ( )

Obtain the elapsed time as a string with format "HH:MM:SS".

Returns
Elapsed time as "HH:MM:SS" string

◆ getElapsedMillis()

long TimeWatcher::getElapsedMillis ( )

Obtain the elapsed time as the integer number of milliseconds.

Returns
Elapsed time in integer milliseconds

◆ getElapsedNanos()

long TimeWatcher::getElapsedNanos ( )

Obtain the elapsed time as the integer number of nanoseconds.

Returns
Elapsed time in integer nanoseconds

◆ getElapsedSeconds()

long TimeWatcher::getElapsedSeconds ( )

Obtain the elapsed time as the integer number of seconds.

Returns
Elapsed time in integer seconds

◆ getElapsedTime()

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.

Returns
Elapsed time
See also
TimeWatcher::start
TimeWatcher::stop

◆ hasNulls()

bool TimeWatcher::hasNulls ( )
private

Check if the time watcher has null start or end time points.

Returns
FALSE if the time watcher does not have neither a null start nor end time point. TRUE otherwise.

◆ reportFormat()

void TimeWatcher::reportFormat ( std::string  msg = "Total elapsed time: ")

Report elapsed time through specified output stream using "HH:MM:SS" format.

Parameters
msgMessage to be shown by the report. By default "Total elapsed time: "

◆ reportMillis()

void TimeWatcher::reportMillis ( std::string  msg = "Total elapsed milliseconds: ")

Report elapsed seconds through specified output stream.

Parameters
msgMessage to be shown by the report. By default "Total elapsed millisecconds: "

◆ reportSeconds()

void TimeWatcher::reportSeconds ( std::string  msg = "Total elapsed seconds: ")

Report elapsed seconds through specified output stream.

Parameters
msgMessage to be shown by the report. By default "Total elapsed seconds: "

Member Data Documentation

◆ tEnd

std::unique_ptr<std::chrono::high_resolution_clock::time_point> TimeWatcher::tEnd
private

End time point.

See also
TimeWatcher::stop

◆ tStart

std::unique_ptr<std::chrono::high_resolution_clock::time_point> TimeWatcher::tStart
private

Start time point.

See also
TimeWatcher::start

The documentation for this class was generated from the following files: