Download this file

chrono.h    42 lines (33 with data), 1.1 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef _CHRONO_H_
#define _CHRONO_H_
/** Easy interface to measuring time intervals */
class Chrono {
public:
/** Initialize, setting the origin time */
Chrono();
/** Re-store current time and return mS since init or last call */
long restart();
/** Re-store current time and return uS since init or last call */
long urestart();
/** Snapshot current time to static storage */
static void refnow();
/** Return interval value in various units.
*
* Frozen means give time since the last refnow call (this is to
* allow for using one actual system call to get values from many
* chrono objects, like when examining timeouts in a queue
*/
long millis(bool frozen = false);
long micros(bool frozen = false);
float secs(bool frozen = false);
/** Return current orig */
long long amicros() const;
struct TimeSpec {
time_t tv_sec; /* Time in seconds */
long tv_nsec; /* And nanoseconds (< 10E9) */
};
private:
TimeSpec m_orig;
static TimeSpec o_now;
};
#endif /* _CHRONO_H_ */