Changeset edca0b8
- Timestamp:
- 10/31/05 16:31:01 (15 years ago)
- Branches:
- 4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
- Children:
- fd9d44c
- Parents:
- f20b30e
- Location:
- examples/tracemark
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/tracemark/Makefile
rc9caf07 redca0b8 4 4 5 5 INCLUDE = -I$(PREFIX)/include 6 CFLAGS = -Wall -Wimplicit -W format -pipe -g -O26 CFLAGS = -Wall -Wimplicit -W -Wformat -pipe -g -Os 7 7 CFLAGS += $(INCLUDE) 8 8 libdir = -L$(PREFIX)/lib -
examples/tracemark/tracemark.c
rc9caf07 redca0b8 46 46 #include <getopt.h> 47 47 #include <inttypes.h> 48 #include <sys/resource.h> 49 #include <unistd.h> 48 50 49 51 #include "libtrace.h" … … 86 88 } 87 89 90 #define TIMER_SUB(res,a,b) \ 91 do { \ 92 res.tv_sec = a.tv_sec - b.tv_sec; \ 93 res.tv_usec = a.tv_usec - b.tv_usec; \ 94 if (res.tv_usec < 0) { \ 95 --res.tv_sec; \ 96 res.tv_usec += 1000000; \ 97 } \ 98 } while(0) 99 88 100 int main(int argc, char *argv[]) { 89 101 … … 91 103 struct timeval start,end; 92 104 struct timeval interval; 105 struct rusage start_usage,end_usage; 93 106 107 getrusage(RUSAGE_SELF,&start_usage); 94 108 gettimeofday(&start,NULL); 95 109 for(i=optind;i<argc;++i) { … … 97 111 } 98 112 gettimeofday(&end,NULL); 99 interval.tv_sec = end.tv_sec - start.tv_sec; 100 interval.tv_usec = end.tv_usec - start.tv_usec; 101 if (interval.tv_usec < 0) { 102 --interval.tv_sec; 103 interval.tv_usec += 1000000; 104 } 113 getrusage(RUSAGE_SELF,&end_usage); 114 115 TIMER_SUB(interval,end,start); 105 116 106 117 printf("Tracemarks: %.02f\n",((double)tot)/(interval.tv_sec+interval.tv_usec/100000)); 118 119 printf("Real: %i.%05is\n",interval.tv_sec,interval.tv_usec); 120 TIMER_SUB(interval,end_usage.ru_utime,start_usage.ru_utime); 121 printf("User: %i.%05is\n",interval.tv_sec,interval.tv_usec); 122 TIMER_SUB(interval,end_usage.ru_stime,start_usage.ru_stime); 123 printf("System: %i.%06is\n",interval.tv_sec,interval.tv_usec); 124 printf("I/O: %li/%li\n",end_usage.ru_inblock-start_usage.ru_inblock, 125 end_usage.ru_oublock-start_usage.ru_oublock); 107 126 return 0; 108 127 }
Note: See TracChangeset
for help on using the changeset viewer.