#include <Iguana/Utilities/classlib/utils/TimeInfo.h>
Public Types | |
typedef double | NanoSecs |
Type for nanosecond times. | |
typedef IntBits< 64 >::SLeast | NanoTicks |
Type for cpu cycle counters. | |
Static Public Member Functions | |
static NanoSecs | elapsedTime (void) |
static unsigned | features () |
static double | ghz (void) |
static void | init (void) |
static double | mhz (void) |
static void | msleep (NanoSecs msecs) |
static void | nanosleep (NanoSecs nanosecs) |
static NanoSecs | processCpuTime (void) |
static NanoSecs | processIdleTime (void) |
static NanoSecs | processRealTime (void) |
static NanoSecs | processSystemTime (void) |
static void | processTimes (NanoSecs &user, NanoSecs &system, NanoSecs &real) |
static NanoSecs | processUserTime (void) |
static NanoTicks | realCycles (void) |
static NanoSecs | realNsecs (void) |
static NanoSecs | resolution (void) |
static void | sleep (NanoSecs secs) |
static NanoSecs | time (void) |
static void | usleep (NanoSecs usecs) |
static NanoTicks | virtualCycles (void) |
static NanoSecs | virtualNsecs (void) |
Static Public Attributes | |
static const int | FEATURE_EXACT_MHZ = 1 |
feature() bit indicating that mhz() is the exact value provided by the system (for the cycle counts vs. | |
static const int | FEATURE_PROCESS_TIMES = 16 |
feature() bit indicating that processUserTime(), processSystemTime() and processCpuTime() are meaningful. | |
static const int | FEATURE_REAL_COUNT_EPOCH = 4 |
feature() bit indicating that realCycles() and realNsecs() can have have system-wide source. | |
static const int | FEATURE_TIME_EPOCH = 2 |
feature() bit indicating that time() may not be process-specific but can have system-wide source. | |
Static Private Member Functions | |
static void | spin (NanoSecs duration, NanoTicks &low, NanoTicks &high) |
Static Private Attributes | |
static NanoSecs | s_clockBase |
static unsigned | s_features |
static double | s_ghz |
static double | s_hiResFactor |
static bool | s_initialised |
This class provides access to, among other things, virtual and real nanosecond-resolution timing info. The implementation does its best to use the cheapest, most trustworthy time calculation method: system-provided high-resolution clocks or reading CPU cycle counters directly. If those are not available, falls back to whatever is likely to produce the best data on the system, usually a system call that promises best resolution.
On systems that do provide accurate monotonic process-specific or system-wide high-resolution clocks (e.g. POSIX CLOCK_MONOTONIC and CLOCK_PROCESS_CPUTIME_ID clocks), they are used in preference to CPU cycle counters. If no such clock is available, the monotonicity cannot always be guaranteed:
In most of these cases it is anybody's guess what the timers read after such an event. Most likely the readings are not linear.
The clock ticks are represented as a 64-bit signed integral type (see NanoTicks). Nanosecond times are represented as a double (see NanoSecs). This accomodates some 290 years worth of cycle counter ticks on a 1GHz CPU. Cycle counters are usually zeroed on boot, so this should be plenty enough for another few years to come. Please note however that not all systems provide cycle counters with this many significant bits.
Definition at line 57 of file TimeInfo.h.
typedef double lat::TimeInfo::NanoSecs |
typedef IntBits<64>::SLeast lat::TimeInfo::NanoTicks |
static unsigned lat::TimeInfo::features | ( | ) | [static] |
static double lat::TimeInfo::ghz | ( | void | ) | [static] |
Referenced by IgApplication::run().
static double lat::TimeInfo::mhz | ( | void | ) | [static] |
Referenced by IgApplication::run().
Referenced by IgApplication::run().
Referenced by IgApplication::run().
static void lat::TimeInfo::processTimes | ( | NanoSecs & | user, | |
NanoSecs & | system, | |||
NanoSecs & | real | |||
) | [static] |
Referenced by IgApplication::run().
static void lat::TimeInfo::spin | ( | NanoSecs | duration, | |
NanoTicks & | low, | |||
NanoTicks & | high | |||
) | [static, private] |
const int lat::TimeInfo::FEATURE_EXACT_MHZ = 1 [static] |
feature() bit indicating that mhz() is the exact value provided by the system (for the cycle counts vs.
nsecs). If not set, the speed was estimated with a calibration loop.
Definition at line 73 of file TimeInfo.h.
const int lat::TimeInfo::FEATURE_PROCESS_TIMES = 16 [static] |
feature() bit indicating that processUserTime(), processSystemTime() and processCpuTime() are meaningful.
Definition at line 86 of file TimeInfo.h.
const int lat::TimeInfo::FEATURE_REAL_COUNT_EPOCH = 4 [static] |
feature() bit indicating that realCycles() and realNsecs() can have have system-wide source.
Definition at line 81 of file TimeInfo.h.
const int lat::TimeInfo::FEATURE_TIME_EPOCH = 2 [static] |
feature() bit indicating that time() may not be process-specific but can have system-wide source.
Definition at line 77 of file TimeInfo.h.
NanoSecs lat::TimeInfo::s_clockBase [static, private] |
Definition at line 144 of file TimeInfo.h.
unsigned lat::TimeInfo::s_features [static, private] |
Definition at line 141 of file TimeInfo.h.
double lat::TimeInfo::s_ghz [static, private] |
Definition at line 142 of file TimeInfo.h.
double lat::TimeInfo::s_hiResFactor [static, private] |
Definition at line 143 of file TimeInfo.h.
bool lat::TimeInfo::s_initialised [static, private] |
Definition at line 140 of file TimeInfo.h.