svcadm(8)을 검색하려면 섹션에서 8 을 선택하고, 맨 페이지 이름에 svcadm을 입력하고 검색을 누른다.
get_nsec_fromepoch(3c)
Standard C Library Functions get_hrusec(3C)
NAME
get_hrusec, get_sec_fromepoch, get_nsec_fromepoch - timestamp for
interval measurements
SYNOPSIS
#include <sys/types.h>
#include <sys/system_stats.h>
void get_hrusec(hrtime_t *usec);
void get_sec_fromepoch(memtime_sec_t *sec);
void get_nsec_fromepoch(hrtime_t *nsec);
DESCRIPTION
These functions are provided for performance reasons. The overhead of
reading time using these functions is minimum as they return time read
from memory. No system calls are involved in get_* functions.
The get_hrusec() function returns high-resolution real time which is
expressed as microseconds 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 settimeofday(3C). This
high-resolution time is suited for performance measurement. Although
the best time accuracy it gives is 1 millisecond unlike gethrtime(3C).
The get_sec_fromepoch() and get_nsec_fromepoch() functions return time
expressed in elapsed seconds from epoch(January 1, 1970) and elapsed
nanoseconds from epoch respectively. Time returned by both these func‐
tions are subject to setting or drifting by adjtime(2) or settimeof‐
day(3C) calls. Note that the accuracy of nsecs returned by
get_nsec_fromepoch() is 1 millisecond.
The in memory time that is read by these functions, is updated by an
interrupt routine and so there will be slight variation compared to the
time reported by the gettimeofday() function. Therefore the time
returned by the get_sec_fromepoch() and get_nsec_fromepoch() functions
should not be compared against time returned by the gettimeofday()
function. For more information, see the gettimeofday(3C),
get_sec_fromepoch(3C) and get_nsec_fromepoch(3C) man pages.
EXAMPLES
Example 1 Timestamping using get_hrusec(),
get_sec_fromepoch(), and
get_nsec_fromepoch():
#include <stdio.h>
#include <unistd.h>
#include <sys/system_stats.h>
#include <time.h>
void main() {
hrtime_t hres1, hres2;
memtime_sec_t sec;
get_hrusec(&hres1);
sleep(1);
get_hrusec(&hres2);
printf("Slept for %lld microseconds\n",
(hres2 - hres1));
get_sec_fromepoch(&sec);
printf("Current time in seconds : %lld\n",
sec);
get_nsec_fromepoch(&hres1);
printf("Current time in nanoseconds: %lld\n",
hres1);
}
ATTRIBUTES
See attributes(7) for descriptions of the following attributes:
tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) ATTRIBUTE TYPEAT‐
TRIBUTE VALUE _ Architecture SPARC and x86 _ Interface StabilityCommit‐
ted _ MT-LevelMT-Safe
SEE ALSO
gettimeofday(3C), gethrtime(3C)
Oracle Solaris 11.4 31 Aug 2016 get_hrusec(3C)