MICROTIME(9) BSD Kernel Developer's Manual MICROTIME(9)NAME
microtime, getmicrotime, nanotime, getnanotime — get the current time
SYNOPSIS
#include <sys/time.h>
void
microtime(struct timeval *tv);
void
getmicrotime(struct timeval *tv);
void
nanotime(struct timespec *ts);
void
getnanotime(struct timespec *tsp);
DESCRIPTION
The microtime() and getmicrotime() functions stores the system time as a
struct timeval at the address specified by tv. The nanotime() and
getnanotime() functions perform the same utility, but record the time as
a struct timespec instead.
Microtime() and nanotime() always query the timecounter to return the
current time as precisely as possible. Whereas getmicrotime() and
getnanotime() functions are abstractions which can alternately return a
less precise, but faster to obtain, time. This behaviour can be toggled
via the kern.timecounter.method sysctl variable:
0 sacrifice precision in favor of faster code execution
1 return the more precise time (the same as calling microtime() or
nanotime()).
The intent of the getmicrotime() and getnanotime() functions is to
enforce the user's preference for timer accuracy versus execution time.
DIAGNOSTICS
Buggy hardware can cause "calcru negative..." when kern.time‐
counter.method is set to 0.
SEE ALSOgetmicrouptime(9), getnanouptime(9), microuptime(9), nanouptime(9),
tvtohz(9)HISTORY
The microtime and nanotime functions first appeared in FreeBSD 3.0 but
existed in other incarnations since 4.4BSD
AUTHORS
This manual page was written by Kelly Yancey ⟨kbyanc@posi.net⟩.
BSD January 3, 2000 BSD