Enumerations | |
enum | TTWACCURACY_LEVEL { TW_ACCURACYLEVELUNKNOWN = 0 , TW_ACCURACYLEVELNORMAL = 1 , TW_ACCURACYLEVELHIGH = 2 } |
Accuracy levels of the high performance timer. Note that the actually achievable accuracy level is system-dependent. More... | |
enum | TTWUNIT { TW_MICROSECONDS = 0 , TW_MILLISECONDS = 1 , TW_SECONDS = 2 } |
Measurement unit selection for the CVB high performance timers. More... | |
Functions | |
cvbbool_t | TWCreate (TIMEWATCH *phTimeWatch) |
Generates a TIMEWATCH object. More... | |
cvbbool_t | TWCreateEx (TIMEWATCH *phTimeWatch) |
Generates a TIMEWATCH object. More... | |
cvbbool_t | TWDestroy (TIMEWATCH hTimeWatch) |
Releases a TimeWatch object that has been created with TWCreate or TWCreateEx. More... | |
cvbbool_t | TWGetAccuracyLevel (TIMEWATCH hTimeWatch, TTWACCURACY_LEVEL *pVal) |
Returns information on the maximum accuracy of a TimeWatch object. More... | |
cvbbool_t | TWGetUnit (TIMEWATCH hTimeWatch, TTWUNIT *pVal) |
This function returns the unit of measurement of time durations for a TIMEWATCH object. More... | |
cvbbool_t | TWReadStopWatch (TIMEWATCH hTimeWatch, short Index, double *pElapsedTime) |
Reads the timer #Index from a TIMEWATCH object. More... | |
cvbbool_t | TWSetUnit (TIMEWATCH hTimeWatch, TTWUNIT Value) |
Sets the time unit of measurement used by the TIMEWATCH object. More... | |
cvbbool_t | TWStartStopWatch (TIMEWATCH hTimeWatch, short Index) |
Starts the timer #Index on the TIMEWATCH object. More... | |
enum TTWACCURACY_LEVEL |
enum TTWUNIT |
Measurement unit selection for the CVB high performance timers.
The setting determines the units that TWReadStopWatch will use to report the amount of time that has elapsed.
Enumerator | |
---|---|
TW_MICROSECONDS | Microseconds (if possible) |
TW_MILLISECONDS | Milliseconds. |
TW_SECONDS | Seconds. |
cvbbool_t TWCreate | ( | TIMEWATCH * | phTimeWatch | ) |
Generates a TIMEWATCH
object.
A TIMEWATCH
object is used for measuring durations like a stop-watch. A time is measured from calling TWStartStopWatch up to the point TWReadStopWatch is called. A timespan is always measure regarding the last call of TWStartStopWatch. Thus if TWReadStopWatch is called twice after a single call to TWStartStopWatch the times are always measured against the one start time.
This function creates a TIMEWATCH
object with millisecond granularity. You can change the granularity by calling TWSetUnit. For the actual precision achievable on your system see the TWGetAccuracyLevel function.
TIMEWATCH
relies on the QueryPerformanceCounter
and QueryPerformanceFrequency
functions. These are not safe to use on multi-processor and variable clock systems! Variable clock systems include mobile processors (power save) and processors with a turbo boost feature. Multi-processor systems do not mean multi-core (like e.g. the Intel Core2Duo processors), but multi-processor systems (like e.g. an Intel Dual Xeon system containing two CPUs with a number of cores each).You can either use the TWCreateEx function to create a safe timer object or disable the clock-changing technologies and/or set the processor affinity of the threads using the function to just one processor.
TIMEWATCH
object based on GetTimeOfDay
.[out] | phTimeWatch | Address to receive the handle of the newly created TimeWatch object. |
TRUE
if successful, FALSE
otherwise.cvbbool_t TWCreateEx | ( | TIMEWATCH * | phTimeWatch | ) |
Generates a TIMEWATCH
object.
A TIMEWATCH
object is used for measuring durations like a stop-watch. A time is measured from calling TWStartStopWatch up to the point TWReadStopWatch is called. A timespan is always measured regarding the last call of TWStartStopWatch. Thus if TWReadStopWatch is called twice after a single call to TWStartStopWatch the times are always measured against the one start time.
This function creates a TIMEWATCH
object with millisecond granularity. You can change the granularity by calling TWSetUnit. For the actual precision achievable on your system see the TWGetAccuracyLevel function.
This function creates a TIMEWATCH
object based on the file time (Windows) or GetTimeOfDay
(Linux). This object normally doesn't achieve microsecond precision on Windows systems, but can be used safely on multi-processor and variable processor-clock systems (see also remarks on TWCreate).
TIMEWATCH
object as TWCreate.[out] | phTimeWatch | Pointer to the address to receive the handle of the newly created TimeWatch object. |
TRUE
if successful, FALSE
otherwise.cvbbool_t TWDestroy | ( | TIMEWATCH | hTimeWatch | ) |
Releases a TimeWatch object that has been created with TWCreate or TWCreateEx.
[in] | hTimeWatch | Handle of TIMEWATCH object to be destroyed. |
cvbbool_t TWGetAccuracyLevel | ( | TIMEWATCH | hTimeWatch, |
TTWACCURACY_LEVEL * | pVal | ||
) |
Returns information on the maximum accuracy of a TimeWatch object.
If the returned accuracy is TW_ACCURACYLEVELHIGH you can achieve microsecond resolution with the timer. On TW_ACCURACYLEVELNORMAL only millisecond resolution can be achieved.
[in] | hTimeWatch | Handle of the TimeWatch object to be queried. |
[out] | pVal | Receives the maximum accuracy level of a TimeWatch object (see also TTWACCURACY_LEVEL). |
cvbbool_t TWGetUnit | ( | TIMEWATCH | hTimeWatch, |
TTWUNIT * | pVal | ||
) |
This function returns the unit of measurement of time durations for a TIMEWATCH
object.
[in] | hTimeWatch | Handle of TimeWatch object to query. |
[out] | pVal | Measurement unit (see TTWUNIT for more information). |
cvbbool_t TWReadStopWatch | ( | TIMEWATCH | hTimeWatch, |
short | Index, | ||
double * | pElapsedTime | ||
) |
Reads the timer #Index from a TIMEWATCH
object.
The elapsed time is returned in units defined by TWSetUnit (milliseconds by default).
[in] | hTimeWatch | Handle of TimeWatch object to work on. |
[in] | Index | Index of the timer to read. |
[out] | pElapsedTime | Receives the time duration between the most recent TWStartStopWatch call and the call to this function. The elapsed time is returned in the units defined by TWSetUnit (milliseconds if TWSetUnit has not been called). |
cvbbool_t TWSetUnit | ( | TIMEWATCH | hTimeWatch, |
TTWUNIT | Value | ||
) |
Sets the time unit of measurement used by the TIMEWATCH
object.
[in] | hTimeWatch | Handle of TimeWatch object to work on. |
[in] | Value | Measurement unit (see TTWUNIT for a list of possible values). |
cvbbool_t TWStartStopWatch | ( | TIMEWATCH | hTimeWatch, |
short | Index | ||
) |
Starts the timer #Index on the TIMEWATCH
object.
[in] | hTimeWatch | Handle of TIMEWATCH object to work on. |
[in] | Index | Index of the timer to be started. |