4 typedef long long hrtime_t
;
11 #ifdef CLOCK_MONOTONIC_RAW
12 int r
= clock_gettime (CLOCK_MONOTONIC_RAW
, &tp
);
14 int r
= clock_gettime (CLOCK_MONOTONIC
, &tp
);
18 rc
= ((hrtime_t
) tp
.tv_sec
) * 1e9
+ (hrtime_t
) tp
.tv_nsec
;
22 volatile long x
; /* temp variable for long calculation */
25 main (int argc
, char **argv
)
28 hrtime_t start
= gethrtime ();
33 for (int j
= 0; j
< 1000000; j
++)
37 while (start
+ 2e9
> gethrtime ());
38 printf("count=%lld x=%lld\n", count
, x
);