27 #include "hrt_utils.h"
36 #if (HRT_REALTIME_METHOD==HRT_USE_CLOCK_GETTIME)
37 printf(
"time.tv_sec = %ld\n", (
long)x->time.tv_sec);
38 printf(
"time.tv_nsec = %ld\n", (
long)x->time.tv_nsec);
39 #elif (HRT_REALTIME_METHOD==HRT_USE_GETTIMEOFDAY)
40 printf(
"time.tv_sec = %ld\n", (
long)x->time.tv_sec);
41 printf(
"time.tv_usec = %ld\n", (
long)x->time.tv_usec);
42 #elif (HRT_REALTIME_METHOD==HRT_USE_TIMES)
43 printf(
"time = %ld\n", (
long)x->time);
44 #elif (HRT_REALTIME_METHOD==HRT_USE_ANSI_TIME)
45 printf(
"time = %ld\n", (
long)x->time);
52 #if (HRT_CPUTIME_METHOD==HRT_USE_CLOCK_GETTIME)
53 printf(
"time.tv_sec = %ld\n", (
long)x->time.tv_sec);
54 printf(
"time.tv_nsec = %ld\n", (
long)x->time.tv_nsec);
55 #elif (HRT_CPUTIME_METHOD==HRT_USE_GETRUSAGE)
56 printf(
"time.ru_utime.tv_sec = %ld\n", (
long)x->time.ru_utime.tv_sec);
57 printf(
"time.ru_utime.tv_usec = %ld\n", (
long)x->time.ru_utime.tv_usec);
58 printf(
"time.ru_stime.tv_sec = %ld\n", (
long)x->time.ru_stime.tv_sec);
59 printf(
"time.ru_stime.tv_usec = %ld\n", (
long)x->time.ru_stime.tv_usec);
60 #elif (HRT_CPUTIME_METHOD==HRT_USE_TIMES)
61 printf(
"time.tms_utime = %ld\n", (
long)x->time.tms_utime);
62 printf(
"time.tms_stime = %ld\n", (
long)x->time.tms_stime);
63 #elif (HRT_CPUTIME_METHOD==HRT_USE_ANSI_CLOCK)
64 printf(
"time = %ld\n", (
long)x->time);
71 hrt_rtprint(&x->rtstamp);
72 hrt_ctprint(&x->ctstamp);
78 const unsigned long loop = 1000000000L;
80 static volatile unsigned long dummy;
81 for (i = 0; i < loop; i++)
86 main(
int argc,
const char* argv[])
88 printf(
"--> main()\n");
95 printf(
"\nmarking time...\n");
97 if ((r = hrt_tnow(&t0)) != 0) {
98 fprintf(stderr,
"error: hrt_now(&t0) returned %d\n", r);
104 printf(
"\nmarking time...\n");
105 if ((r = hrt_tnow(&t1)) != 0) {
106 fprintf(stderr,
"error: hrt_now(&t1) returned %d\n", r);
110 printf(
"\namount of times:\n");
111 double rtmicros = hrt_rtmicros(&t1.rtstamp, &t0.rtstamp);
112 double ctmicros = hrt_ctmicros(&t1.ctstamp, &t0.ctstamp);
113 printf(
"real = %.3f us\n", rtmicros);
114 printf(
"cpu = %.3f us\n", ctmicros);
116 printf(
"\n<-- main()\n");