PCL
|
High-resolution time stamp. More...
#include <ElapsedTime.h>
Public Member Functions | |
ElapsedTime () | |
ElapsedTime (const ElapsedTime &)=default | |
operator IsoString () const | |
operator String () const | |
double | operator() () const |
ElapsedTime & | operator= (const ElapsedTime &)=default |
void | Reset () |
IsoString | ToIsoString () const |
String | ToString () const |
Static Public Member Functions | |
static double | TimeStamp () |
static IsoString | ToIsoString (double seconds, int width=0, int precision=3) |
static String | ToString (double s, int width=0, int precision=3) |
Friends | |
double | operator- (const ElapsedTime &t1, const ElapsedTime &t2) |
ElapsedTime is a platform-independent, monotonically nondecreasing high-resolution time stamp based on hardware time resources that are independent on any external time reference. The underlying implementation uses monotonic clock services on Linux and FreeBSD (via clock_gettime() system calls), performance counters on Windows, and Mach absolute time system services on macOS.
Example of use:
Timing resolution should be better than one microsecond on all platforms, but the actual resolution achieved is hardware and system dependent.
This class is thread-safe: it can be instantiated and its member functions can be safely invoked from multiple running threads.
Definition at line 130 of file ElapsedTime.h.
|
inline |
Constructs a new ElapsedTime object and initializes it with the current system time, which will be the starting point of subsequent time interval evaluations.
Definition at line 139 of file ElapsedTime.h.
|
default |
Copy constructor.
|
inline |
IsoString conversion operator. Equivalent to ToIsoString().
Definition at line 197 of file ElapsedTime.h.
|
inline |
String conversion operator. Equivalent to ToString().
Definition at line 205 of file ElapsedTime.h.
|
inline |
Returns the time interval elapsed since the last object initialization, expressed in seconds. An ElapsedTime object is initialized either when it is constructed, or through a subsequent call to the Reset() member function.
Definition at line 160 of file ElapsedTime.h.
|
default |
Copy assignment operator. Returns a reference to this object.
|
inline |
Initializes this ElapsedTime object with a new time stamp, which will be the starting point of subsequent time interval evaluations.
Definition at line 169 of file ElapsedTime.h.
|
inlinestatic |
Returns a 64-bit, monotonically nondecreasing time stamp.
The returned value is the time elapsed in seconds since an arbitrary, platform-dependent starting time that will remain invariant during the current execution of the calling module.
With the current implementation, accuracy of timestamps should be better than one microsecond on all supported platforms.
Definition at line 220 of file ElapsedTime.h.
|
inline |
Returns an 8-bit string representation of the time interval elapsed since the last object initialization. See operator()() and ToIsoString( double ) for detailed information.
Definition at line 179 of file ElapsedTime.h.
|
inlinestatic |
Returns an 8-bit string representation of the specified time interval in seconds.
The returned string has one of the following formats:
(1) u.uuu us | u.uuu is the time t in microseconds if t ≤ 0.001 s |
(2) m.mmm ms | m.mmm is the time t in milliseconds if t ≤ 1.0 s |
(3) s.sss s | s.sss is the time t in seconds if t ≤ 60.0 s |
(4) mm:ss.ss | Zero-padded minutes and seconds if t ≤ 3600 s |
(5) hh:mm:ss.s | Same as (4) with zero-padded hours if t ≤ 86400 s |
(6) d:hh:mm:ss | Same as (5) with elapsed days if t ≥ 86400 |
If width > 0 and t ≤ 60, the integer part of the represented microseconds, milliseconds or seconds will be right-padded in a field of width space characters.
The precision argument specifies the maximum number of decimal digits represented, and must be in the [0,3] range. Depending on the magnitude of the specified seconds argument, the precision will be reduced by one or two units automatically, with a minimum of zero digits. The default precision is 3 digits.
The output format is chosen automatically to generate the most significant representation. If the specified interval is negative (toward the past), a minus sign is prepended to the returned string.
Definition at line 328 of file ElapsedTime.h.
|
inline |
Returns a Unicode string representation of the time interval elapsed since the last object initialization. See operator()() and ToIsoString( double ) for detailed information.
Definition at line 189 of file ElapsedTime.h.
|
inlinestatic |
Returns a Unicode string representation of the specified time interval s in seconds. See ToIsoString( double ) for information on the representation format and parameters.
Definition at line 338 of file ElapsedTime.h.
|
friend |
Returns the time interval in seconds elapsed between the starting points of two ElapsedTime objects t1 and t2. The result is positive if t2 precedes t1, negative if t1 precedes t2, zero if and only if either t1 and t2 are references to the same instance, or if one of the objects has been constructed as a copy of the other.
Definition at line 350 of file ElapsedTime.h.