libcommonc++  0.7
StopWatch Class Reference

A stopwatch-style timer. More...

#include <StopWatch.h++>

Public Member Functions

 StopWatch ()
 Construct a new StopWatch. More...
 
virtual ~StopWatch ()
 Destructor. More...
 
void start ()
 Start the timer. More...
 
void stop ()
 Stop the timer. More...
 
void pause ()
 Pause the timer. More...
 
void resume ()
 Resume the timer. More...
 
void reset ()
 Reset the timer. More...
 
uint64_t elapsedKernelTime () const
 Return the total elapsed kernel time for this timer (up to the point where the timer was last stopped) in milliseconds. More...
 
uint64_t elapsedUserTime () const
 Return the total elapsed user time for this timer (up to the point where the timer was last stopped) in milliseconds. More...
 
uint64_t elapsedRealTime () const
 Return the total elapsed real time for this timer (up to the point where the timer was last stopped) in milliseconds. More...
 
bool isRunning () const
 Determine if this timer is running. More...
 

Detailed Description

A stopwatch-style timer.

The timer can be used for code benchmarking and other timing tasks. The timer accumulates time while it is "running"; this accumulated time (in kernel time, user time, and real time) can be queried while the timer is stopped.

Author
Mark Lindner

Constructor & Destructor Documentation

◆ StopWatch()

StopWatch ( )

Construct a new StopWatch.

◆ ~StopWatch()

~StopWatch ( )
virtual

Destructor.

Member Function Documentation

◆ elapsedKernelTime()

uint64_t elapsedKernelTime ( ) const
inline

Return the total elapsed kernel time for this timer (up to the point where the timer was last stopped) in milliseconds.

◆ elapsedRealTime()

uint64_t elapsedRealTime ( ) const
inline

Return the total elapsed real time for this timer (up to the point where the timer was last stopped) in milliseconds.

◆ elapsedUserTime()

uint64_t elapsedUserTime ( ) const
inline

Return the total elapsed user time for this timer (up to the point where the timer was last stopped) in milliseconds.

◆ isRunning()

bool isRunning ( ) const
inline

Determine if this timer is running.

◆ pause()

void pause ( )
inline

Pause the timer.

Attempting to pause a timer that isn't running will have no effect. Equivalent to stop().

◆ reset()

void reset ( )

Reset the timer.

All elapsed times are cleared to 0.

◆ resume()

void resume ( )
inline

Resume the timer.

Attempting to resume a timer that isn't paused will have no effect. Equivalent to start().

◆ start()

void start ( )

Start the timer.

Attemping to start an already running timer will have no effect.

◆ stop()

void stop ( )

Stop the timer.

Attempting to stop a timer that isn't running will have no effect.


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