Query: gethrtime
OS: freebsd
Section: 3c
Links: freebsd man pages all man pages
Forums: unix linux community forum categories
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
gethrtime(3C) Standard C Library Functions gethrtime(3C)NAMEgethrtime, gethrvtime - get high resolution timeSYNOPSIS#include <sys/time.h> hrtime_t gethrtime(void); hrtime_t gethrvtime(void);DESCRIPTIONThe gethrtime() function returns the current high-resolution real time. Time is expressed as nanoseconds since some arbitrary time in the past; it is not correlated in any way to the time of day, and thus is not subject to resetting or drifting by way of adjtime(2) or settime- ofday(3C). The hi-res timer is ideally suited to performance measurement tasks, where cheap, accurate interval timing is required. The gethrvtime() function returns the current high-resolution LWP virtual time, expressed as total nanoseconds of execution time. The gethrtime() and gethrvtime() functions both return an hrtime_t, which is a 64-bit (long long) signed integer.EXAMPLESThe following code fragment measures the average cost of getpid(2): hrtime_t start, end; int i, iters = 100; start = gethrtime(); for (i = 0; i < iters; i++) getpid(); end = gethrtime(); printf("Avg getpid() time = %lld nsec ", (end - start) / iters);ATTRIBUTESSee attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+SEE ALSOproc(1), adjtime(2), gettimeofday(3C), settimeofday(3C), attributes(5)NOTESAlthough the units of hi-res time are always the same (nanoseconds), the actual resolution is hardware dependent. Hi-res time is guaran- teed to be monotonic (it won't go backward, it won't periodically wrap) and linear (it won't occasionally speed up or slow down for adjust- ment, like the time of day can), but not necessarily unique: two sufficiently proximate calls may return the same value. SunOS 5.10 7 Sep 2004 gethrtime(3C)
Related Man Pages |
---|
gethrtime(3c) - opensolaris |
gethrtime(3c) - mojave |
gethrtime(3c) - x11r4 |
gethrtime(3c) - suse |
gethrtime(3c) - php |
Similar Topics in the Unix Linux Community |
---|
time functions help? |
Use of alloca function |
Measure thread execution (in C, unix) |
lightweight function for measuring time ( better than clock_getime ) |