]> rtime.felk.cvut.cz Git - can-benchmark.git/commitdiff
latester: Add --quiet option
authorMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 9 Dec 2010 22:03:39 +0000 (23:03 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 9 Dec 2010 22:03:39 +0000 (23:03 +0100)
latester/latester.c

index 6a78872afeb1ebd25e627485d6713cb0594c8296..d5d7b4ba9b7ac71c7827e53e9e2b0f5d2c9c4291 100644 (file)
@@ -62,6 +62,7 @@ struct options {
        char *name;
        int length;
        int userhist;
+       int quiet;
 
        /* Temporary variables */
        FILE *f_msgs;
@@ -633,6 +634,7 @@ struct poptOption optionsTable[] = {
        { "name",   'n', POPT_ARG_STRING,                         &opt.name, 0,      "Prefix of the generated files"},
        { "length", 'l', POPT_ARG_INT|POPT_ARGFLAG_SHOW_DEFAULT,  &opt.length, 0,    "The length of generated messages", "bytes"},
        { "userhist", 'u', POPT_ARG_NONE,                         &opt.userhist, 0,  "Generate histogram from userspace timestamps"},
+       { "quiet",  'q', POPT_ARG_NONE,                           &opt.quiet, 0,     "Do not print progress and statistics"},
        POPT_AUTOHELP
        { NULL, 0, 0, NULL, 0 }
 };
@@ -693,8 +695,10 @@ int parse_options(int argc, const char *argv[])
 
 void print_progress()
 {
-       printf("\rSent %5d, in progress %5d", count, msg_in_progress);
-       fflush(stdout);
+       if (! opt.quiet) {
+               printf("\rSent %5d, in progress %5d", count, msg_in_progress);
+               fflush(stdout);
+       }
 }
 
 int main(int argc, const char *argv[])
@@ -765,7 +769,8 @@ int main(int argc, const char *argv[])
                }
        }
        print_progress();
-       printf("\n");
+       if (!opt.quiet)
+               printf("\n");
 
        stats.lost = msg_in_progress;
 
@@ -781,13 +786,13 @@ int main(int argc, const char *argv[])
        
        fprintf(opt.f_stat, "sent=%d\n", count);
        fprintf(opt.f_stat, "overrun=%d\n", stats.overrun);
-       if (stats.overrun)
+       if (stats.overrun && !opt.quiet)
                printf("overrun=%d\n", stats.overrun);
        fprintf(opt.f_stat, "enobufs=%d\n", stats.enobufs);
-       if (stats.enobufs)
+       if (stats.enobufs && !opt.quiet)
                printf("enobufs=%d\n", stats.enobufs);
        fprintf(opt.f_stat, "lost=%d\n", stats.lost);
-       if (stats.lost)
+       if (stats.lost && !opt.quiet)
                printf("lost=%d\n", stats.lost);
 
        fclose(opt.f_stat);