50 #define rt_start(rt) \
51 if ((time(&(rt.tv1)) == ((time_t) - 1))) { \
58 if ((time(&(rt.tv2)) == ((time_t) - 1))) { \
63 #define rt_u_useconds(rt) rt_w_useconds(rt)
65 #define rt_s_useconds(rt) rt_w_useconds(rt)
67 #define rt_w_useconds(rt) (1.0e6 * (rt.tv2 - rt.tv1))
72 #include <sys/resource.h>
78 struct rusage rut1, rut2;
79 struct timeval tv1, tv2;
82 #define rt_start(rt) \
83 if ((getrusage(RUSAGE_SELF, &rt.rut1) < 0) || \
84 (gettimeofday(&(rt.tv1), NULL) < 0)) { \
85 perror("rusage/gettimeofday"); \
91 if ((getrusage(RUSAGE_SELF, &rt.rut2) < 0) || \
92 (gettimeofday(&(rt.tv2), NULL) < 0)) { \
93 perror("rusage/gettimeofday"); \
97 #define rt_u_useconds(rt) \
98 (((double)rt.rut2.ru_utime.tv_usec + \
99 (double)rt.rut2.ru_utime.tv_sec * 1000000) - \
100 ((double)rt.rut1.ru_utime.tv_usec + \
101 (double)rt.rut1.ru_utime.tv_sec * 1000000))
103 #define rt_s_useconds(rt) \
104 (((double)rt.rut2.ru_stime.tv_usec + \
105 (double)rt.rut2.ru_stime.tv_sec * 1000000) - \
106 ((double)rt.rut1.ru_stime.tv_usec + \
107 (double)rt.rut1.ru_stime.tv_sec * 1000000))
109 #define rt_w_useconds(rt) \
110 (((double)rt.tv2.tv_usec + (double)rt.tv2.tv_sec * 1000000) - \
111 ((double)rt.tv1.tv_usec + (double)rt.tv1.tv_sec * 1000000))
117 #define rt_zero(rt) bzero(&(rt), sizeof(Rtimer));
119 #define rt_seconds(rt) (rt_w_useconds(rt) / 1000000)
121 #define rt_sprint(buf, rt) rt_sprint_safe(buf, rt)
char * rt_sprint_safe(char *buf, Rtimer rt)