ezEngine  Milestone 7
ezStopwatch Class Reference

A helper class to time the execution of code or other actions. More...

#include <Stopwatch.h>

Public Member Functions

 ezStopwatch ()
 The constructor will automatically start the stopwatch.
 
void StopAndReset ()
 Stops the stopwatch and resets the running total to zero. Afterwards a new time measure can be started using Resume().
 
void Pause ()
 Pauses the stopwatch so that the running total will not increase any further. More...
 
void Resume ()
 Resumes the stopwatch to accumulate more time. More...
 
ezTime GetRunningTotal ()
 Returns the current running total. This can be called while the stopwatch is running or while it is paused. More...
 
ezTime Checkpoint ()
 This function returns the time that has passed since the last call to Checkpoint() or since the construction of the object. More...
 

Private Attributes

bool m_bRunning
 
ezTime m_LastUpdate
 
ezTime m_LastCheckpoint
 
ezTime m_TotalDuration
 

Detailed Description

A helper class to time the execution of code or other actions.

Member Function Documentation

ezTime ezStopwatch::Checkpoint ( )

This function returns the time that has passed since the last call to Checkpoint() or since the construction of the object.

You can use this function to measure the time between steps. Just call Checkpoint() after each step to retrieve the time it took. To retrieve the time since the stopwatch started, call GetRunningTotal().

Note
Checkpoint() is not affected by calls to Pause(), Resume() or StopAndReset(). It always returns the time difference to the last call to Checkpoint().
ezTime ezStopwatch::GetRunningTotal ( )

Returns the current running total. This can be called while the stopwatch is running or while it is paused.

The running total can be frozen by calling Pause(), which allows to read the result back at a later point in time. It can be reset to zero using StopAndReset().

void ezStopwatch::Pause ( )

Pauses the stopwatch so that the running total will not increase any further.

The stopwatch can be resumed via Resume() later and will then accumulate more time. The time in between will not contribute to the running total.

void ezStopwatch::Resume ( )

Resumes the stopwatch to accumulate more time.

If the stopwatch is already running, this function has no effect. To start a completely new time measure, first call StopAndReset() and then Resume().


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