NAME | SYNOPSIS | FEATURES | DESCRIPTION | RETURN VALUE | ERRORS | EXAMPLES | ATTRIBUTES
#include <timer/chBench.h>int sysBench(int option, int *uTime);
PERF
The sysBench system call returns a microsecond time value suitable for benchmarking. The option argument specifies whether the benchmark time value is for the beginning or end point of the benchmark interval. The argument utime is the address of an integer which sysBench uses to store a time value in microseconds.
It should be noted that the time value returned by sysBench does not necessarily correspond to any actual time, it could simply be an instantaneous value from a clock chip. On some platforms, time values can "wrap-around" after a certain amount of time, causing a subsequent bench point to return a lower time value, making the benchmark interval invalid. For example, on x86 architectures the maximum interval measurable using sysBench is 5 milliseconds.
Three options are currently supported:
This option starts a benchmark interval by enabling benchmarking, disabling interrupts, and returns an instantaneous microsecond time value in uTime.
This option returns an instantaneous microsecond time value in uTime. This option should be called between a K_BSTART and a K_BSTOP call.
This disables benchmarking, re-enables interrupts appropriately, and returns another instantaneous microsecond time value in uTime.
Upon successful completion K_OK is returned. Otherwise, a negative error code is returned.
An invalid option was passed as an argument, or the benchmark commands were not issued in the correct order (for example, K_BSTART was not issued before B_STOP or two K_BSTART commands were issued one after another).
This small code fragment illustrates a typical usage of sysBench.
int startTime, stopTime, intervalTime; if ((res = sysBench(K_BSTART, &startTime)) != K_OK) { /* A benchmark was pending */ return res; } /* ... code to be measured ... */ if ((res = sysBench(K_BSTOP, &stopTime)) != K_OK) { /* K_BSTOP was already issued */ return res; } intervalTime = stopTime - startTime; |
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
---|---|
Interface Stability | Evolving |
NAME | SYNOPSIS | FEATURES | DESCRIPTION | RETURN VALUE | ERRORS | EXAMPLES | ATTRIBUTES