Changeset 568
- Timestamp:
- 02/09/06 03:55:26 (7 years ago)
- File:
-
- 1 edited
-
branches/libtrace2/examples/count/tracestats.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/libtrace2/examples/count/tracestats.c
r397 r568 72 72 uint64_t count = 0; 73 73 uint64_t bytes = 0; 74 struct timeval starttime, packettime; 75 76 starttime.tv_sec = 0; 77 starttime.tv_usec = 0; 74 78 75 79 fprintf(stderr,"%s:\n",uri); … … 82 86 break; 83 87 } 88 89 packettime = trace_get_timeval(&packet); 90 /* 91 * save the time of the first packet we see so that we can later 92 * do some maths and work out how long this trace was 93 */ 94 if(starttime.tv_sec == 0 && starttime.tv_usec == 0) 95 { 96 starttime.tv_sec = packettime.tv_sec; 97 starttime.tv_usec = packettime.tv_usec; 98 } 84 99 85 100 for(i=0;i<filter_count;++i) { … … 94 109 } 95 110 111 96 112 for(i=0;i<filter_count;++i) { 97 113 printf("%30s:\t%12"PRIu64"\t%12"PRIu64"\t%7.03f\n",filters[i].expr,filters[i].count,filters[i].bytes,filters[i].count*100.0/count); … … 102 118 totcount+=count; 103 119 totbytes+=bytes; 120 121 /* subtract the time of the first packet from the time of the last packet we saw */ 122 timersub(&packettime, &starttime, &packettime); 123 printf("Total Duration: %d.%06d seconds\n", (int)packettime.tv_sec, (int)packettime.tv_usec); 104 124 105 125 trace_destroy(trace);
Note: See TracChangeset
for help on using the changeset viewer.
