[#BloombergLP-bsls-TimeUtil]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bsls.adoc[bsls]::TimeUtil
:relfileprefix: ../../
:mrdocs:

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

== Synopsis

Declared in `&lt;bsls&lowbar;timeutil&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
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 &quot;raw&quot; method returning an opaque native time value and a conversion method returning a value in nanoseconds&period;

== Type Aliases

[cols="1"]
|===
| Name
| xref:BloombergLP/bsls/TimeUtil/OpaqueNativeTime.adoc[`OpaqueNativeTime`] 
|===


== Static Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bsls/TimeUtil/convertRawTime.adoc[`convertRawTime`] 
| Convert the specified `rawTime` to a value in nanoseconds, referenced to an arbitrary but fixed origin, and return the result of the conversion&period; Note that this method is thread&hyphen;safe only if `initialize` has been called before&period;
| xref:BloombergLP/bsls/TimeUtil/getProcessSystemTimer.adoc[`getProcessSystemTimer`] 
| Return the instantaneous values of a platform&hyphen;dependent timer for the current process system time in absolute nanoseconds referenced to an arbitrary but fixed origin&period; If the system call fails return &hyphen;1&period; Note that this method is thread&hyphen;safe only if `initialize` has been called before&period;
| xref:BloombergLP/bsls/TimeUtil/getProcessTimers.adoc[`getProcessTimers`] 
| Load into the specified `systemTimer` and `userTimer` the instantaneous values of platform&hyphen;dependent system timer and user timer in absolute nanoseconds referenced to an arbitrary but fixed origin&period; If the system call fails fill both time arguments with &hyphen;1&period; Note that this method is thread&hyphen;safe only if `initialize` has been called before&period;
| xref:BloombergLP/bsls/TimeUtil/getProcessUserTimer.adoc[`getProcessUserTimer`] 
| Return the instantaneous values of a platform&hyphen;dependent timer for the current process user time in absolute nanoseconds referenced to an arbitrary but fixed origin&period; If the system call fails return &hyphen;1&period; Note that this method is thread&hyphen;safe only if `initialize` has been called before&period;
| xref:BloombergLP/bsls/TimeUtil/getThreadSystemTimer.adoc[`getThreadSystemTimer`] 
| Return the instantaneous values of a platform&hyphen;dependent timer for the current thread system time in absolute nanoseconds referenced to an arbitrary but fixed origin&period; Return &hyphen;1 on platforms where per&hyphen;thread CPU timers are unavailable or in case of a system call failure&period; Note that this method is thread&hyphen;safe only if `initialize` has been called before&period;
| xref:BloombergLP/bsls/TimeUtil/getThreadTimers.adoc[`getThreadTimers`] 
| Load into the specified `systemTimer` and `userTimer` the instantaneous values of platform&hyphen;dependent system timer and user timer for the current thread, in absolute nanoseconds referenced to an arbitrary but fixed origin&period; Load &hyphen;1 into both timers on platforms where per&hyphen;thread CPU timers are unavailable or in case of a system call failure&period; Note that this method is thread&hyphen;safe only if `initialize` has been called before&period;
| xref:BloombergLP/bsls/TimeUtil/getThreadUserTimer.adoc[`getThreadUserTimer`] 
| Return the instantaneous values of a platform&hyphen;dependent timer for the current thread user time in absolute nanoseconds referenced to an arbitrary but fixed origin&period; Return &hyphen;1 on platforms where per&hyphen;thread CPU timers are unavailable or in case of a system call failure&period; Note that this method is thread&hyphen;safe only if `initialize` has been called before&period;
| xref:BloombergLP/bsls/TimeUtil/getTimer.adoc[`getTimer`] 
| Return the instantaneous value of a platform&hyphen;dependent system timer in absolute nanoseconds referenced to an arbitrary but fixed origin&period; Note that this method is thread&hyphen;safe only if `initialize` has been called before&period;
| xref:BloombergLP/bsls/TimeUtil/getTimerRaw.adoc[`getTimerRaw`] 
| Load into the specified `timeValue` the value of an opaque, platform&hyphen;dependent type representing the current time&period; `timeValue` must be converted by the `convertRawTime` method to conventional units (nanoseconds)&period; This method is intended to facilitate accurate timing of small segments of code, and care must be used in interpreting the results&period; Note that this method is thread&hyphen;safe only if `initialize` has been called before&period;
| xref:BloombergLP/bsls/TimeUtil/initialize.adoc[`initialize`] 
| Do a platform&hyphen;dependent initialization for the utilities&period; Note that the other methods in this component are guaranteed to be thread&hyphen;safe only after calling this method&period;
|===



[.small]#Created with https://www.mrdocs.com[MrDocs]#
