unsigned count;
unsigned oneattime;
char *name;
- int histogram;
- int file;
int length;
int userhist;
+ int quiet;
/* Temporary variables */
FILE *f_msgs;
mi->ts_rx_final = ts_user;
mi->received = frame;
- if (opt.histogram)
- histogram_add(&histogram, get_msg_latency_us(mi));
+ histogram_add(&histogram, get_msg_latency_us(mi));
ret = write(completion_pipe[1], &mi, sizeof(mi));
if (ret == -1)
{ "oneattime",'o', POPT_ARG_NONE, &opt.oneattime,0, "Send the next message only when the previous was finally received"},
{ "verbose",'v', POPT_ARG_NONE, NULL, 'v', "Send the next message only when the previous was finally received"},
{ "name", 'n', POPT_ARG_STRING, &opt.name, 0, "Prefix of the generated files"},
- { "file", 'f', POPT_ARG_NONE, &opt.file, 0, "Store all message data in a file", "filename"},
- { "histogram", 'h', POPT_ARG_NONE, &opt.histogram, 0, "Store histogram in file", "filename"},
{ "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 }
};
if (opt.oneattime && opt.period_us)
error(1, 0, "oneattime and period cannot be specified at the same time");
- if (opt.name && opt.file) {
+ if (opt.name) {
char *f = talloc_asprintf(local, "%s-msgs.txt", opt.name);
opt.f_msgs = fopen(f, "w");
if (!opt.f_msgs)
error(1, errno, "fopen: %s", f);
}
- if (opt.name && opt.histogram) {
+ if (opt.name) {
char *f = talloc_asprintf(local, "%s-hist.txt", opt.name);
opt.f_hist = fopen(f, "w");
if (!opt.f_hist)
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[])
for (i=0; i<MAX_INFOS; i++)
msg_infos[i].id = -1;
- if (opt.histogram) {
- histogram_init(&histogram, 5000000, 1);
- }
+ histogram_init(&histogram, 5000000, 1);
ret = pipe(completion_pipe);
if (ret == -1)
ret = read(completion_pipe[0], &mi, sizeof(mi));
if (ret < sizeof(mi))
error(1, errno, "read completion returned %d", ret);
- if (opt.file)
- msg_info_print(opt.f_msgs, mi);
+ msg_info_print(opt.f_msgs, mi);
msg_info_free(mi);
completed++;
}
}
}
print_progress();
- printf("\n");
+ if (!opt.quiet)
+ printf("\n");
stats.lost = msg_in_progress;
close(completion_pipe[0]);
close(completion_pipe[1]);
- if (opt.histogram) {
- histogram_fprint(&histogram, opt.f_hist);
- fclose(opt.f_hist);
- }
- if (opt.file)
- fclose(opt.f_msgs);
+ histogram_fprint(&histogram, opt.f_hist);
+ fclose(opt.f_hist);
+ fclose(opt.f_msgs);
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);