Support Forum G3D Web Page |
Provides accurate measurement of durations. More...
Public Member Functions | |
Stopwatch (const String &name="Stopwatch") | |
template<class Duration = chrono::nanoseconds> | |
Duration | elapsedDuration () const |
Provides the elapsed time as a std::chrono::duration. More... | |
RealTime | elapsedTime () const |
Amount of time between the most recent tick and tock calls. More... | |
bool | enabled () const |
/deprecated Use ContinuousStopwatch More... | |
void | printElapsedTime (const String &s=String()) |
/deprcated Use ContinuousStopwatch More... | |
void | reset () |
/deprecated Use ContinuousStopwatch More... | |
void | setEnabled (bool e) |
/deprecated Use ContinuousStopwatch More... | |
template<class Duration = chrono::nanoseconds> | |
Duration | smoothElapsedDuration () const |
Provides the smooth elapsed time as a std::chrono::duration. More... | |
RealTime | smoothElapsedTime () const |
Time-smoothed value that is stable to the nearest 1%. More... | |
void | tick () |
Call at the beginning of the period that you want timed. More... | |
void | tock () |
Call at the end of the period that you want timed. More... | |
Provides accurate measurement of durations.
Example 1: For profiling code
Stopwatch sw; sw.tick(); ...timed code... sw.tock();
screenPrintf("%f\n", sw.elapsedTime());
Example 2: For profiling sequences of code
Stopwatch sw; sw.setEnabled(true); slowOperation(); sw.printElapsedTime("slowOperation"); kdTree.balance(); sw.printElapsedTime("Balance tree");
G3D::Stopwatch::Stopwatch | ( | const String & | name = "Stopwatch" | ) |
|
inline |
Provides the elapsed time as a std::chrono::duration.
Use this if you want resolution smaller than seconds before rounding.
|
inline |
Amount of time between the most recent tick and tock calls.
0 if tick has never been called.
|
inline |
/deprecated Use ContinuousStopwatch
/deprcated Use ContinuousStopwatch
|
inline |
/deprecated Use ContinuousStopwatch
|
inline |
/deprecated Use ContinuousStopwatch
|
inline |
Provides the smooth elapsed time as a std::chrono::duration.
Use this if you want resolution smaller than seconds before rounding.
|
inline |
Time-smoothed value that is stable to the nearest 1%.
This is useful if you are displaying elapsed time in real-time and want a stable number.
void G3D::Stopwatch::tick | ( | ) |
Call at the beginning of the period that you want timed.
void G3D::Stopwatch::tock | ( | ) |
Call at the end of the period that you want timed.