#include <stop_watch.h>
Nevrax France
Definition at line 48 of file stop_watch.h.
Public Member Functions | |
void | addMeasurement (TTickDuration t) |
Add an external duration (in ticks unit) to the average queue. | |
void | addTime (TTickDuration t) |
Add time (in ticks unit) to the current measurement. | |
CStopWatch (uint queueLength=0) | |
Constructor. Set a non-zero queueLength for partial average calculation. | |
TMsDuration | getAverageDuration () const |
Average of the duration. | |
TMsDuration | getDuration () const |
Elapsed time in millisecond (call it after stop()). | |
TMsDuration | getPartialAverage () const |
Average duration of the queueLength last durations (using the queueLength argument specified in the constructor). | |
uint32 | measurementNumber () const |
Number of measurements. | |
void | pause () |
Pause. | |
void | resume () |
Resume. | |
void | start () |
Begin measurement. | |
void | stop () |
End measurement. | |
TTickDuration | sumTicks () const |
Sum of the measured durations (in ticks). | |
Private Attributes | |
TTicks | _BeginTime |
TTickDuration | _ElapsedTicks |
uint32 | _MeasurementNumber |
uint | _QLength |
std::deque< TTickDuration > | _Queue |
TTickDuration | _SumTicks |
|
Constructor. Set a non-zero queueLength for partial average calculation.
Definition at line 39 of file stop_watch.cpp. References uint.
00039 : 00040 _BeginTime( 0 ), 00041 _ElapsedTicks( 0 ), 00042 _SumTicks( 0 ), 00043 _MeasurementNumber( 0 ), 00044 _Queue(), 00045 _QLength( queueLength ) 00046 {} |
|
Add an external duration (in ticks unit) to the average queue.
Definition at line 112 of file stop_watch.cpp. References _MeasurementNumber, _QLength, _Queue, _SumTicks, t, and NLMISC::TTickDuration.
|
|
Add time (in ticks unit) to the current measurement.
Definition at line 80 of file stop_watch.cpp. References _ElapsedTicks, t, and NLMISC::TTickDuration.
00081 { 00082 _ElapsedTicks += t; 00083 } |
|
Average of the duration.
Definition at line 155 of file stop_watch.cpp. References _MeasurementNumber, _SumTicks, and NLMISC::TMsDuration.
00156 { 00157 return (TMsDuration)(CTime::ticksToSecond( _SumTicks / _MeasurementNumber ) * 1000.0); 00158 } |
|
Elapsed time in millisecond (call it after stop()).
Definition at line 134 of file stop_watch.cpp. References _ElapsedTicks, and NLMISC::TMsDuration.
00135 { 00136 return (TMsDuration)(CTime::ticksToSecond( _ElapsedTicks ) * 1000.0); 00137 } |
|
Average duration of the queueLength last durations (using the queueLength argument specified in the constructor).
Definition at line 143 of file stop_watch.cpp. References _Queue, and NLMISC::TMsDuration.
00144 { 00145 if (_Queue.size() == 0) 00146 return (TMsDuration)0; 00147 else 00148 return (TMsDuration)(CTime::ticksToSecond( accumulate( _Queue.begin(), _Queue.end(), 0 ) / _Queue.size() ) * 1000.0); 00149 } |
|
Number of measurements.
Definition at line 92 of file stop_watch.h. References _MeasurementNumber, and uint32.
00092 { return _MeasurementNumber; } |
|
Pause.
Definition at line 62 of file stop_watch.cpp. References _ElapsedTicks, and NLMISC::TTickDuration.
00063 { 00064 _ElapsedTicks += (TTickDuration)(CTime::getPerformanceTime() - _BeginTime); 00065 } |
|
Resume.
Definition at line 71 of file stop_watch.cpp.
00072 { 00073 _BeginTime = CTime::getPerformanceTime(); 00074 } |
|
Begin measurement.
Definition at line 52 of file stop_watch.cpp. References _ElapsedTicks.
00053 { 00054 _BeginTime = CTime::getPerformanceTime(); 00055 _ElapsedTicks = 0; 00056 } |
|
End measurement.
Definition at line 89 of file stop_watch.cpp. References _ElapsedTicks, _MeasurementNumber, _QLength, _Queue, _SumTicks, and NLMISC::TTickDuration.
00090 { 00091 _ElapsedTicks += (TTickDuration)(CTime::getPerformanceTime() - _BeginTime); 00092 00093 // Setup average 00094 _SumTicks += _ElapsedTicks; 00095 ++_MeasurementNumber; 00096 00097 // Setup partial average 00098 if ( _QLength != 0 ) 00099 { 00100 _Queue.push_back( _ElapsedTicks ); 00101 if ( _Queue.size() > _QLength ) 00102 { 00103 _Queue.pop_front(); 00104 } 00105 } 00106 } |
|
Sum of the measured durations (in ticks).
Definition at line 89 of file stop_watch.h. References _SumTicks, and NLMISC::TTickDuration.
00089 { return _SumTicks; } |
|
Definition at line 96 of file stop_watch.h. |
|
Definition at line 97 of file stop_watch.h. Referenced by addTime(), getDuration(), pause(), start(), and stop(). |
|
Definition at line 100 of file stop_watch.h. Referenced by addMeasurement(), getAverageDuration(), measurementNumber(), and stop(). |
|
Definition at line 103 of file stop_watch.h. Referenced by addMeasurement(), and stop(). |
|
Definition at line 102 of file stop_watch.h. Referenced by addMeasurement(), getPartialAverage(), and stop(). |
|
Definition at line 99 of file stop_watch.h. Referenced by addMeasurement(), getAverageDuration(), stop(), and sumTicks(). |