This struct provides a namespace for a set of platform‐neutral pure procedures to access real‐time system clock functionality. High‐resolution time functions intended for interval‐timing return an interval in nanoseconds (1 nsec = 1E‐9 sec) as a platform‐independent 64‐bit integer.

Synopsis

Declared in <bsls_timeutil.h>

struct TimeUtil;

Description

For maximum performance on some platforms where fetching the native clock is significantly faster than converting the fetched value to nanoseconds, this class also provides a "raw" method returning an opaque native time value and a conversion method returning a value in nanoseconds.

Type Aliases

Static Member Functions

Name

Description

convertRawTime

Convert the specified rawTime to a value in nanoseconds, referenced to an arbitrary but fixed origin, and return the result of the conversion. Note that this method is thread‐safe only if initialize has been called before.

getProcessSystemTimer

Return the instantaneous values of a platform‐dependent timer for the current process system time in absolute nanoseconds referenced to an arbitrary but fixed origin. If the system call fails return ‐1. Note that this method is thread‐safe only if initialize has been called before.

getProcessTimers

Load into the specified systemTimer and userTimer the instantaneous values of platform‐dependent system timer and user timer in absolute nanoseconds referenced to an arbitrary but fixed origin. If the system call fails fill both time arguments with ‐1. Note that this method is thread‐safe only if initialize has been called before.

getProcessUserTimer

Return the instantaneous values of a platform‐dependent timer for the current process user time in absolute nanoseconds referenced to an arbitrary but fixed origin. If the system call fails return ‐1. Note that this method is thread‐safe only if initialize has been called before.

getThreadSystemTimer

Return the instantaneous values of a platform‐dependent timer for the current thread system time in absolute nanoseconds referenced to an arbitrary but fixed origin. Return ‐1 on platforms where per‐thread CPU timers are unavailable or in case of a system call failure. Note that this method is thread‐safe only if initialize has been called before.

getThreadTimers

Load into the specified systemTimer and userTimer the instantaneous values of platform‐dependent system timer and user timer for the current thread, in absolute nanoseconds referenced to an arbitrary but fixed origin. Load ‐1 into both timers on platforms where per‐thread CPU timers are unavailable or in case of a system call failure. Note that this method is thread‐safe only if initialize has been called before.

getThreadUserTimer

Return the instantaneous values of a platform‐dependent timer for the current thread user time in absolute nanoseconds referenced to an arbitrary but fixed origin. Return ‐1 on platforms where per‐thread CPU timers are unavailable or in case of a system call failure. Note that this method is thread‐safe only if initialize has been called before.

getTimer

Return the instantaneous value of a platform‐dependent system timer in absolute nanoseconds referenced to an arbitrary but fixed origin. Note that this method is thread‐safe only if initialize has been called before.

getTimerRaw

Load into the specified timeValue the value of an opaque, platform‐dependent type representing the current time. timeValue must be converted by the convertRawTime method to conventional units (nanoseconds). This method is intended to facilitate accurate timing of small segments of code, and care must be used in interpreting the results. Note that this method is thread‐safe only if initialize has been called before.

initialize

Do a platform‐dependent initialization for the utilities. Note that the other methods in this component are guaranteed to be thread‐safe only after calling this method.

Created with MrDocs