ScopedStopWatch Class Reference

Measures the time this stop watch was inside the current scope. More...

#include <ArmarXCore/core/time/ScopedStopWatch.h>

+ Inheritance diagram for ScopedStopWatch:

Public Member Functions

 ScopedStopWatch (std::function< void(const Duration &)> callback, ClockType clockType=ClockType::Virtual)
 Constructs a ScopedStopWatch. More...
 
virtual ~ScopedStopWatch () override
 Destructs the ScopedStopWatch. More...
 
- Public Member Functions inherited from StopWatch
bool isStopped () const
 Returns whether the timer is stopped or is actively measuring time. More...
 
void reset ()
 Resets the timer. More...
 
DateTime startingTime () const
 Returns the date/time at starting the timer. More...
 
Duration stop ()
 Stops the timer and returns the measured duration. More...
 
Duration stopAndReset ()
 Stops and resets the timer. More...
 
DateTime stoppingTime () const
 Returns the date/time at stopping the timer. More...
 
 StopWatch (ClockType clockType=ClockType::Virtual)
 Constructs a StopWatch and starts it immediately. More...
 
virtual ~StopWatch ()
 Destructs the StopWatch. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from StopWatch
static Duration measure (std::function< void(void)> subjectToMeasure, ClockType clockType=ClockType::Virtual)
 Measures the duration needed to execute the given lambda and returns it. More...
 

Detailed Description

Measures the time this stop watch was inside the current scope.

Takes a lambda as construction parameter (taking an IceUtil::Time as parameter), which will be called at destruction (i.e., when the scope was left).

Code example:

{
ScopedStopWatch sw{[](const Duration& duration) {
std::cout << "Operation took " << duration << ".";
}};
long_operation();
}

Definition at line 32 of file ScopedStopWatch.h.

Constructor & Destructor Documentation

◆ ScopedStopWatch()

ScopedStopWatch ( std::function< void(const Duration &)>  callback,
ClockType  clockType = ClockType::Virtual 
)

Constructs a ScopedStopWatch.

Parameters
callbackCallback lambda which will be called at destruction with measured time.
clockTypeClock type.

Definition at line 13 of file ScopedStopWatch.cpp.

◆ ~ScopedStopWatch()

~ScopedStopWatch ( )
overridevirtual

Destructs the ScopedStopWatch.

Definition at line 21 of file ScopedStopWatch.cpp.

+ Here is the call graph for this function:

The documentation for this class was generated from the following files:
armarx::core::time::ScopedStopWatch::ScopedStopWatch
ScopedStopWatch(std::function< void(const Duration &)> callback, ClockType clockType=ClockType::Virtual)
Constructs a ScopedStopWatch.
Definition: ScopedStopWatch.cpp:13
armarx::armem::Duration
armarx::core::time::Duration Duration
Definition: forward_declarations.h:14