Changeset d2df7c4


Ignore:
Timestamp:
09/10/15 16:42:23 (5 years ago)
Author:
Shane Alcock <salcock@…>
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:
ab7e4ee
Parents:
9346e4a
Message:

Make -c option work for tracertstats

It's only an approximate stopping point (a lower bound to be exact), as we
only check whether we've passed the count in the reporting thread.

Removed references to tracertstats_parallel from Makefile.am

Location:
tools/tracertstats
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • tools/tracertstats/Makefile.am

    r29bbef0 rd2df7c4  
    1 bin_PROGRAMS = tracertstats tracertstats_parallel
     1bin_PROGRAMS = tracertstats
    22man_MANS = tracertstats.1
    33EXTRA_DIST = $(man_MANS)
     
    1616tracertstats_SOURCES = tracertstats.c output.h output.c $(OUTPUT_MODULES)
    1717tracertstats_LDADD = -ltrace $(OUTPUT_PNG_LD)
    18 tracertstats_parallel_SOURCES = tracertstats_parallel.c output.h output.c $(OUTPUT_MODULES)
    19 tracertstats_parallel_LDADD = -ltrace $(OUTPUT_PNG_LD)
  • tools/tracertstats/tracertstats.1

    rd6dc0f6 rd2df7c4  
    66[ -f | --filter bpf ]
    77[ -i | --interval interval ]
     8[ -t | --threads max ]
    89[ -c | --count count ]
    910[ -o | --output-format csv,txt,png,html ]
     
    3435.TP
    3536.PD 0
     37.BI \-t " max"
     38.TP
     39.PD
     40.BI \-\^\-threads " max"
     41Use \fImax\fR packet processing threads. The default is 4 threads, but adding
     42more or less threads may improve performance.
     43
     44.TP
     45.PD 0
    3646.BI \-c " count"
    3747.TP
    3848.PD
    3949.BI \-\^\-count " count"
    40 Output results every \fIcount\fR packets.
     50Stop after processing this amount of packets. Note that this is only a
     51lower bound as this is only evaluated once per thread per interval.
    4152
    4253.TP
  • tools/tracertstats/tracertstats.c

    rc3cb9f9 rd2df7c4  
    6363#define DEFAULT_OUTPUT_FMT "txt"
    6464
    65 struct libtrace_t *trace;
    6665char *output_format=NULL;
    67 
    6866int merge_inputs = 0;
    6967int threadcount = 4;
     68int filter_count=0;
    7069
    7170struct filter_t {
     
    7574        uint64_t bytes;
    7675} *filters = NULL;
    77 int filter_count=0;
    78 uint64_t totcount;
    79 uint64_t totbytes;
    8076
    8177uint64_t packet_count=UINT64_MAX;
    8278double packet_interval=UINT32_MAX;
    83 
    8479
    8580struct output_data_t *output = NULL;
     
    135130
    136131static uint64_t glob_last_ts = 0;
    137 static void process_result(libtrace_t *trace UNUSED, int mesg,
     132static void process_result(libtrace_t *trace, int mesg,
    138133                           libtrace_generic_t data,
    139134                           libtrace_thread_t *sender UNUSED) {
    140         static uint64_t ts = 0;
     135        uint64_t ts = 0;
     136        static bool stopped = false;
     137        static uint64_t packets_seen = 0;
    141138        int j;
    142139        result_t *res;
     140
     141        if (stopped)
     142                return;
    143143
    144144        switch (mesg) {
     
    157157                }
    158158                count += res->total.count;
     159                packets_seen += res->total.count;
    159160                bytes += res->total.bytes;
    160161                for (j = 0; j < filter_count; j++) {
     
    164165                free(res);
    165166        }
     167
     168        /* Be careful to only call pstop once from within this thread! */
     169        if (packets_seen > packet_count) {
     170                trace_pstop(trace);
     171                stopped = true;
     172        }
    166173}
    167174
     
    214221                        trace_publish_result(trace, t, last_key, tmp, RESULT_USER);
    215222                        trace_post_reporter(trace);
    216                         free(results);
    217223                        results = NULL;
    218224                }
     
    239245static void run_trace(char *uri)
    240246{
     247        libtrace_t *trace = NULL;
    241248        if (!merge_inputs)
    242249                create_output(uri);
     
    253260                return;
    254261        }
    255         /*
    256         if (trace_start(trace)==-1) {
    257                 trace_perror(trace,"trace_start");
    258                 trace_destroy(trace);
    259                 if (!merge_inputs)
    260                         output_destroy(output);
    261                 return;
    262         }*/
    263262        trace_set_combiner(trace, &combiner_ordered, (libtrace_generic_t){0});
    264263        trace_set_tracetime(trace, true);
    265264        trace_set_perpkt_threads(trace, threadcount);
    266 
    267         //trace_set_hasher(trace, HASHER_CUSTOM, &bad_hash, NULL);
    268265
    269266        if (trace_get_information(trace)->live) {
     
    294291       
    295292}
     293
    296294// TODO Decide what to do with -c option
    297295static void usage(char *argv0)
     
    300298        "%s flags libtraceuri [libtraceuri...]\n"
    301299        "-i --interval=seconds  Duration of reporting interval in seconds\n"
    302         "-c --count=packets     Exit after count packets received\n"
     300        "-c --count=packets     Exit after count packets have been processed\n"
    303301        "-t --threads=max       Create 'max' processing threads (default: 4)\n"
    304302        "-o --output-format=txt|csv|html|png Reporting output format\n"
     
    350348                                break;
    351349                        case 'c':
    352                                 packet_count=atoi(optarg);
     350                                packet_count=strtoul(optarg, NULL, 10);
    353351                                break;
    354352                        case 'o':
Note: See TracChangeset for help on using the changeset viewer.