#include <sxTimer.h>

Public Member Functions | |
| sxTimer () | |
| Construct timer object. | |
| sxTimer (const sxTimer &ot) | |
| sxTimer (qint64 b) | |
| sxTimer & | operator= (const sxTimer &ot) |
| void | Start () |
| Start the timer. | |
| qint64 | uElapsed () const |
| Elapsed time in usec since started. | |
| int | mElapsed () const |
| qint64 | Tic () |
| Start stopwatch function. | |
| qint64 | uToc () const |
| Get elapsed time in microsecond(s) since Tic() called. | |
| double | mToc () const |
| Get elapsed time in milisecond(s) since Tic() called. | |
| double | Toc () const |
| Get elapsed time in second(s) since Tic() called. | |
| qint64 | Base () const |
| Based of the timer object. | |
Static Public Member Functions | |
| static qint64 | now () |
| Calculate current time stamp (in microseconds). | |
| static void | uwait2 (unsigned int usec, bool *cancel=0) |
| Block the execution for given microsecond(s). | |
| static void | uwait (unsigned int usec) |
| static void | mwait (unsigned int msec) |
| Block the execution for given millisecond(s). | |
| static void | idle () |
| Idle for a moment. | |
This utility class for timer/stopwatch related function. Here is an example of how to using the class.
1) Measuring execution time
sxTimer::mwait(10); //wait for 10 milliseconds //wait for 100 microsecond(s) with cancelable thread. //this mainly for multithreading bool flag; sxTimer::uwait(100, &flag);
| sxTimer::sxTimer | ( | ) |
| void sxTimer::idle | ( | ) | [static] |
Idle for a moment.
In windows, this function call Sleep(0)
| double sxTimer::mToc | ( | ) | const |
Get elapsed time in milisecond(s) since Tic() called.
References uElapsed().
| void sxTimer::mwait | ( | unsigned int | msec | ) | [static] |
Block the execution for given millisecond(s).
| msec | number of millisecond to wait |
References now().
| qint64 sxTimer::now | ( | ) | [static] |
Calculate current time stamp (in microseconds).
This function in win32 using QueryPerformanceCounter and QueryPerformanceFrequency. In linux/unix, using gettimeofday.
Referenced by mwait(), Start(), uElapsed(), and uwait2().
| void sxTimer::Start | ( | ) |
| qint64 sxTimer::Tic | ( | ) |
| double sxTimer::Toc | ( | ) | const |
Get elapsed time in second(s) since Tic() called.
References uElapsed().
| qint64 sxTimer::uElapsed | ( | ) | const |
| qint64 sxTimer::uToc | ( | ) | const |
Get elapsed time in microsecond(s) since Tic() called.
References uElapsed().
| void sxTimer::uwait2 | ( | unsigned int | usec, | |
| bool * | cancel = 0 | |||
| ) | [static] |
Block the execution for given microsecond(s).
| usec | number of microsecond to sleep | |
| cancel | pointer to cancel flag |
References now().
1.5.7.1