gethrtime(3c) 맨 페이지 - 윈디하나의 솔라나라

개요

섹션
맨 페이지 이름
검색(S)

gethrtime(3c)

Standard C Library Functions                                     gethrtime(3C)



NAME
       gethrtime, gethrvtime - get high resolution time

SYNOPSIS
       #include <sys/time.h>

       hrtime_t gethrtime(void);


       hrtime_t gethrvtime(void);

DESCRIPTION
       The gethrtime() function returns the current high-resolution real time.
       Time is expressed as nanoseconds since some arbitrary time in the past.
       It  does  not  necessarily represent time elapsed since boot, nor 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). 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 vir‐
       tual 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.

EXAMPLES
       The 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\n", (end − start) / iters);


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 _ MT-LevelMT-Safe


SEE ALSO
       proc(1),  adjtime(2),  time(2),   gettimeofday(3C),   settimeofday(3C),
       attributes(7)

NOTES
       Although  the  units  of hi-res time are always the same (nanoseconds),
       the actual resolution is hardware dependent. Hi-res time is  guaranteed
       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  adjustment,
       like the time of day can), but not necessarily unique: two sufficiently
       proximate calls may return the same value.



Oracle Solaris 11.4               18 Nov 2016                    gethrtime(3C)
맨 페이지 내용의 저작권은 맨 페이지 작성자에게 있습니다.
RSS ATOM XHTML 5 CSS3