Changeset 62b3c4e for tools/tracestats/tracestats_parallel.c
- Timestamp:
- 03/05/15 15:44:30 (6 years ago)
- Branches:
- 4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, 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:
- ab3fa18
- Parents:
- b023181
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/tracestats/tracestats_parallel.c
r0ec8a7c r62b3c4e 105 105 static void* per_packet(libtrace_t *trace, libtrace_thread_t *t, 106 106 int mesg, libtrace_generic_t data, 107 libtrace_thread_t *sender )107 libtrace_thread_t *sender UNUSED) 108 108 { 109 109 // Using first entry as total and those after for filter counts … … 158 158 } 159 159 160 static void report_result(libtrace_t *trace UNUSED, libtrace_result_t *result, libtrace_message_t *mesg) { 160 static void report_result(libtrace_t *trace UNUSED, int mesg, 161 libtrace_generic_t data, 162 libtrace_thread_t *sender UNUSED) { 161 163 static uint64_t count=0, bytes=0; 162 uint64_t packets;163 164 int i; 164 if (result) { 165 int j; 165 libtrace_stat_t *stats; 166 167 switch (mesg) { 168 case MESSAGE_RESULT: 166 169 /* Get the results from each core and sum 'em up */ 167 assert(libtrace_result_get_key( result) == 0);168 statistics_t * res = libtrace_result_get_value( result).ptr;170 assert(libtrace_result_get_key(data.res) == 0); 171 statistics_t * res = libtrace_result_get_value(data.res).ptr; 169 172 count += res[0].count; 170 173 bytes += res[0].bytes; 171 for ( j = 0; j < filter_count; j++) {172 filters[ j].count += res[j+1].count;173 filters[ j].bytes += res[j+1].bytes;174 for (i = 0; i < filter_count; i++) { 175 filters[i].count += res[i+1].count; 176 filters[i].bytes += res[i+1].bytes; 174 177 } 175 178 free(res); 176 } else switch (mesg->code) { 177 libtrace_stat_t *stats; 178 case MESSAGE_STOPPING: 179 stats = trace_get_statistics(trace, NULL); 180 printf("%-30s\t%12s\t%12s\t%7s\n","filter","count","bytes","%"); 181 for(i=0;i<filter_count;++i) { 182 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); 183 filters[i].bytes=0; 184 filters[i].count=0; 185 } 186 if (stats->received_valid) 187 fprintf(stderr,"%30s:\t%12" PRIu64"\n", 188 "Input packets", stats->received); 189 if (stats->filtered_valid) 190 fprintf(stderr,"%30s:\t%12" PRIu64"\n", 191 "Filtered packets", stats->filtered); 192 if (stats->dropped_valid) 193 fprintf(stderr,"%30s:\t%12" PRIu64"\n", 194 "Dropped packets",stats->dropped); 195 if (stats->accepted_valid) 196 fprintf(stderr,"%30s:\t%12" PRIu64 "\n", 197 "Accepted packets", stats->accepted); 198 if (stats->errors_valid) 199 fprintf(stderr,"%30s:\t%12" PRIu64 "\n", 200 "Erred packets", stats->errors); 201 printf("%30s:\t%12"PRIu64"\t%12" PRIu64 "\n","Total",count,bytes); 202 totcount+=count; 203 totbytes+=bytes; 204 } 205 } 206 207 static uint64_t rand_hash(libtrace_packet_t * pkt, void *data) { 179 break; 180 case MESSAGE_STOPPING: 181 stats = trace_get_statistics(trace, NULL); 182 printf("%-30s\t%12s\t%12s\t%7s\n","filter","count","bytes","%"); 183 for(i=0;i<filter_count;++i) { 184 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); 185 filters[i].bytes=0; 186 filters[i].count=0; 187 } 188 if (stats->received_valid) 189 fprintf(stderr,"%30s:\t%12" PRIu64"\n", 190 "Input packets", stats->received); 191 if (stats->filtered_valid) 192 fprintf(stderr,"%30s:\t%12" PRIu64"\n", 193 "Filtered packets", stats->filtered); 194 if (stats->dropped_valid) 195 fprintf(stderr,"%30s:\t%12" PRIu64"\n", 196 "Dropped packets",stats->dropped); 197 if (stats->accepted_valid) 198 fprintf(stderr,"%30s:\t%12" PRIu64 "\n", 199 "Accepted packets", stats->accepted); 200 if (stats->errors_valid) 201 fprintf(stderr,"%30s:\t%12" PRIu64 "\n", 202 "Erred packets", stats->errors); 203 printf("%30s:\t%12"PRIu64"\t%12" PRIu64 "\n","Total",count,bytes); 204 totcount+=count; 205 totbytes+=bytes; 206 } 207 } 208 209 static uint64_t rand_hash(libtrace_packet_t * pkt UNUSED, void *data UNUSED) { 208 210 return rand(); 209 211 } 210 212 211 static uint64_t bad_hash(libtrace_packet_t * pkt , void *data) {213 static uint64_t bad_hash(libtrace_packet_t * pkt UNUSED, void *data UNUSED) { 212 214 return 0; 213 215 } … … 234 236 //trace_parallel_config(trace, TRACE_OPTION_SET_PERPKT_THREAD_COUNT, &option); 235 237 trace_parallel_config(trace, TRACE_OPTION_SET_CONFIG, &uc); 236 trace_set_combiner(trace, &combiner_ordered, (libtrace_generic_t ypes_t){0});238 trace_set_combiner(trace, &combiner_ordered, (libtrace_generic_t){0}); 237 239 238 240 //trace_parallel_config(trace, TRACE_OPTION_SET_MAPPER_BUFFER_SIZE, &option);
Note: See TracChangeset
for help on using the changeset viewer.