+ histogram_fprint(&histogram, opt.f_hist);
+ histogram_fprint(&histogram_gw, opt.f_hist_gw);
+ if (opt.f_hist)
+ fclose(opt.f_hist);
+ if (opt.f_hist_gw)
+ fclose(opt.f_hist_gw);
+ if (opt.f_msgs)
+ fclose(opt.f_msgs);
+
+ if (opt.f_stat) {
+ struct histogram_stats hs;
+ fprintf(opt.f_stat, "cmdline='");
+ for (i=0; i<argc; i++)
+ fprintf(opt.f_stat, "%s%s", argv[i], i < argc-1 ? " " : "");
+ fprintf(opt.f_stat, "'\n");
+
+ timespec_subtract(&diff, &stats.tac, &stats.tic);
+ fprintf(opt.f_stat, "duration=%s # seconds\n", tstamp_str(NULL, &diff));
+
+ fprintf(opt.f_stat, "sent=%d\n", count);
+ fprintf(opt.f_stat, "overrun=%d\n", 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 && !opt.quiet)
+ printf("enobufs=%d\n", stats.enobufs);
+ fprintf(opt.f_stat, "lost=%d\n", stats.lost);
+ if (stats.lost && !opt.quiet)
+ printf("lost=%d\n", stats.lost);
+ fprintf(opt.f_stat, "timeouts=%d\n", stats.timeouts);
+ if (stats.timeouts && !opt.quiet)
+ printf("timeouts=%d\n", stats.timeouts);
+ fprintf(opt.f_stat, "invalid_frame=%d\n", stats.timeouts);
+ if (stats.timeouts && !opt.quiet)
+ printf("invalid_frame=%d\n", stats.timeouts);
+
+ histogram_stats(&histogram_gw, &hs);
+ double avg = hs.count ? (double)hs.sum/hs.count : 0;
+ fprintf(opt.f_stat, "avg=%g\n", avg);
+ fprintf(opt.f_stat, "out_of_range_below=%d\n", hs.below);
+ fprintf(opt.f_stat, "out_of_range_above=%d\n", hs.above);
+ for (i = 0; i <= 20; i++)
+ fprintf(opt.f_stat, "percentile%d=%d\n", i*5, hs.percentile[i*5]);
+
+ fclose(opt.f_stat);