![]() |
Gorgon Game Engine
|
Millisecond based timer. More...
Public Member Functions | |
Timer (unsigned passed=0) | |
Default constructor. More... | |
unsigned | Get () const |
Returns total time passed. More... | |
operator unsigned () const | |
Returns total time passed. More... | |
void | Reset () |
Resets the passed time. Adjusts starting time of the timer. More... | |
void | Set (unsigned passed) |
Changes the passed time. Adjusts starting time of the timer. More... | |
void | ShowDialog (const std::string &name="Time passed", const std::string &title="Performance timer") const |
Shows a UI dialog displaying the amount of time passed. More... | |
void | Start () |
Starts the timer from this instant. More... | |
Timer & | Tick () |
Counts the time since the last Start, Tick, Set, Reset or from the contruction of the timer and adds this duration to time passed. More... | |
Millisecond based timer.
This class allows performance calculations. Constructing a new timer effectively starts it. However, explicit start might be used to exclude the time passed from the Timer construction or last Tick. All output functions are constant and do not modify the timer. Because of this, a Tick method might be necessary. The display functions will always report the time passed at the last tick. Pause function is not required and not included. Pause can be performed by issuing a Tick and using Start at the end of the pause. This class has a very low memory and processing overhead.
Example:
Timer | ( | unsigned | passed = 0 | ) |
Default constructor.
Starts the timer right away. If another start point is required, issuing a Start method before calling Tick will over ride previous starting point.
passed | can be specified to start the timer from the given duration. |
References Gorgon::Time::GetTime().
unsigned Get | ( | ) | const |
Returns total time passed.
This value updates only when Tick method is called. Therefore, to get a recent value, Tick method should be called prior to this method.
operator unsigned | ( | ) | const |
Returns total time passed.
This value updates only when Tick method is called. Therefore, to get a recent value, Tick method should be called prior to this method.
void Reset | ( | ) |
Resets the passed time. Adjusts starting time of the timer.
References Timer::Set().
void Set | ( | unsigned | passed | ) |
Changes the passed time. Adjusts starting time of the timer.
References Gorgon::Time::GetTime().
void ShowDialog | ( | const std::string & | name = "Time passed" , |
const std::string & | title = "Performance timer" |
||
) | const |
Shows a UI dialog displaying the amount of time passed.
Like Get method, this method does not update the time passed. Therefore, to get a recent value, Tick method should be called prior to this method.
name | that will be used to label the timer. It will be displayed within the window dialog. |
title | of the dialog window. |
void Start | ( | ) |
Starts the timer from this instant.
Any progress since the last Tick will be ignored. This allows pausing and starting the timer after construction.
References Gorgon::Time::GetTime().
Timer& Tick | ( | ) |
Counts the time since the last Start, Tick, Set, Reset or from the contruction of the timer and adds this duration to time passed.
Use Get method to retrieve total ellapsed time.
References Gorgon::Time::GetTime().