52 #define rt_start(rt) \ 53 if((time(&(rt.tv1)) == ((time_t) -1))) { \ 60 if((time(&(rt.tv2)) == ((time_t) -1))) { \ 65 #define rt_u_useconds(rt) rt_w_useconds(rt) 67 #define rt_s_useconds(rt) rt_w_useconds(rt) 69 #define rt_w_useconds(rt) (1.0e6 * (rt.tv2 - rt.tv1)) 74 #include <sys/resource.h> 80 struct rusage rut1, rut2;
81 struct timeval tv1, tv2;
84 #define rt_start(rt) \ 85 if((getrusage(RUSAGE_SELF, &rt.rut1) < 0) \ 86 || (gettimeofday(&(rt.tv1), NULL) < 0)) { \ 87 perror("rusage/gettimeofday"); \ 94 if((getrusage(RUSAGE_SELF, &rt.rut2) < 0) \ 95 || (gettimeofday(&(rt.tv2), NULL) < 0)) { \ 96 perror("rusage/gettimeofday"); \ 101 #define rt_u_useconds(rt) \ 102 (((double)rt.rut2.ru_utime.tv_usec + \ 103 (double)rt.rut2.ru_utime.tv_sec*1000000) \ 104 - ((double)rt.rut1.ru_utime.tv_usec + \ 105 (double)rt.rut1.ru_utime.tv_sec*1000000)) 107 #define rt_s_useconds(rt) \ 108 (((double)rt.rut2.ru_stime.tv_usec + \ 109 (double)rt.rut2.ru_stime.tv_sec*1000000) \ 110 - ((double)rt.rut1.ru_stime.tv_usec + \ 111 (double)rt.rut1.ru_stime.tv_sec*1000000)) 113 #define rt_w_useconds(rt) \ 114 (((double)rt.tv2.tv_usec + \ 115 (double)rt.tv2.tv_sec*1000000) \ 116 - ((double)rt.tv1.tv_usec + \ 117 (double)rt.tv1.tv_sec*1000000)) 127 #define rt_zero(rt) bzero(&(rt),sizeof(Rtimer)); 129 #define rt_seconds(rt) (rt_w_useconds(rt)/1000000) 131 #define rt_sprint(buf, rt) rt_sprint_safe(buf,rt) char * rt_sprint_safe(char *buf, Rtimer rt)