pub unsafe extern "C" fn rtapi_get_time() -> c_longlong
Expand description

rtapi_get_time returns the current time in nanoseconds. Depending on the RTOS, this may be time since boot, or time since the clock period was set, or some other time. Its absolute value means nothing, but it is monotonically increasing and can be used to schedule future events, or to time the duration of some activity. Returns a 64 bit value. The resolution of the returned value may be as good as one nano-second, or as poor as several microseconds. May be called from init/cleanup code, and from within realtime tasks.

Experience has shown that the implementation of this function in some RTOS/Kernel combinations is horrible. It can take up to several microseconds, which is at least 100 times longer than it should, and perhaps a thousand times longer. Use it only if you MUST have results in seconds instead of clocks, and use it sparingly. See rtapi_get_clocks() instead.

Note that longlong math may be poorly supported on some platforms, especially in kernel space. Also note that rtapi_print() will NOT print longlongs. Most time measurements are relative, and should be done like this: deltat = (long int)(end_time - start_time); where end_time and start_time are longlong values returned from rtapi_get_time, and deltat is an ordinary long int (32 bits). This will work for times up to about 2 seconds.