NAME
microtime
,
getmicrotime
, microuptime
,
getmicrouptime
,
microboottime
, nanotime
,
getnanotime
, nanouptime
,
getnanouptime
, nanoruntime
,
nanoboottime
, bintime
,
binuptime
, binruntime
,
binboottime
, gettime
,
getuptime
—
system clocks
SYNOPSIS
#include
<sys/time.h>
void
microtime
(struct timeval
*tv);
void
getmicrotime
(struct timeval
*tv);
void
microuptime
(struct timeval
*tv);
void
getmicrouptime
(struct timeval
*tv);
void
microboottime
(struct timeval
*tv);
void
nanotime
(struct timespec
*tv);
void
getnanotime
(struct timespec
*tv);
void
nanouptime
(struct timespec
*tv);
void
getnanouptime
(struct timespec
*tv);
void
nanoruntime
(struct timespec
*tv);
void
nanoboottime
(struct timespec
*tv);
void
bintime
(struct bintime *tv);
void
binuptime
(struct bintime
*tv);
void
binruntime
(struct bintime
*tv);
void
binboottime
(struct bintime
*tv);
time_t
gettime
(void);
time_t
getuptime
(void);
DESCRIPTION
This family of functions return different system clocks in various formats. The "uptime" functions return the monotonically increasing time since boot. The "runtime" functions return the monotonically increasing time since boot, less any time spent suspended. The "boottime" functions return the UTC time at which the system booted. The "time" functions return the current UTC time. The various formats for the result are specified with:
- bin
- result in struct bintime containing seconds and 64-bit fractions of seconds.
- nano
- result in struct timespec containing seconds and nanoseconds
- micro
- result in struct timeval containing seconds and microseconds
The functions with the "get" prefix return a less precise result, but much faster. They should be used where a precision of 10 msec is acceptable and where performance is critical. The functions without the "get" prefix return the best timestamp that can be produced in the given format.
CODE REFERENCES
The implementation of these functions is partly machine dependent, but the bulk of the code is in the file sys/kern/kern_tc.c.