dodo  0.0.1
A C++ library to create containerized Linux services
dodo::common::StopWatch Class Reference

StopWatch timing class. More...

#include <util.hpp>

Collaboration diagram for dodo::common::StopWatch:

Public Member Functions

 StopWatch ()
 Construct a StopWatch. More...
 
double getElapsedSeconds () const
 Return the number of seconds between. More...
 
double restart ()
 Stop the stopwatch, start the Stopwatch again and return the elapsed time since previous start. More...
 
void start ()
 Start the stopwatch. More...
 
double stop ()
 Stop the stopwatch. More...
 

Private Attributes

std::chrono::time_point< std::chrono::high_resolution_clock > start_
 Start time. More...
 
std::chrono::time_point< std::chrono::high_resolution_clock > stop_
 Stop time. More...
 

Detailed Description

StopWatch timing class.

sw.start();
...
sw.stop();
double seconds = sw.getElapsedSecond();

Definition at line 54 of file util.hpp.

Constructor & Destructor Documentation

◆ StopWatch()

dodo::common::StopWatch::StopWatch ( )
inline

Construct a StopWatch.

The start time is taken here, or can be reset by calling start().

Definition at line 60 of file util.hpp.

References start_, and stop_.

Member Function Documentation

◆ getElapsedSeconds()

double dodo::common::StopWatch::getElapsedSeconds ( ) const
inline

Return the number of seconds between.

Definition at line 93 of file util.hpp.

References start_, and stop_.

Referenced by stop().

Here is the caller graph for this function:

◆ restart()

double dodo::common::StopWatch::restart ( )
inline

Stop the stopwatch, start the Stopwatch again and return the elapsed time since previous start.

Returns
the elapsed time in seconds.

Definition at line 84 of file util.hpp.

References start(), and stop().

Here is the call graph for this function:

◆ start()

void dodo::common::StopWatch::start ( )
inline

Start the stopwatch.

If calling start() is omitted, start_ is set to the time StopWatch::StopWatch() was called.

Definition at line 69 of file util.hpp.

References start_, and stop_.

Referenced by restart().

Here is the caller graph for this function:

◆ stop()

double dodo::common::StopWatch::stop ( )
inline

Stop the stopwatch.

Returns
the elapsed time in seconds.

Definition at line 78 of file util.hpp.

References getElapsedSeconds(), and stop_.

Referenced by restart().

Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ start_

std::chrono::time_point<std::chrono::high_resolution_clock> dodo::common::StopWatch::start_
private

Start time.

Definition at line 101 of file util.hpp.

Referenced by getElapsedSeconds(), start(), and StopWatch().

◆ stop_

std::chrono::time_point<std::chrono::high_resolution_clock> dodo::common::StopWatch::stop_
private

Stop time.

Definition at line 107 of file util.hpp.

Referenced by getElapsedSeconds(), start(), stop(), and StopWatch().


The documentation for this class was generated from the following file:
dodo::common::StopWatch::StopWatch
StopWatch()
Construct a StopWatch.
Definition: util.hpp:60