Change the first line to show total ops, time, total size, and rate. The totals are useful for understanding the total throughput of the application. --- filters/stats/nbdkit-stats-filter.pod | 8 ++++---- filters/stats/stats.c | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/filters/stats/nbdkit-stats-filter.pod b/filters/stats/nbdkit-stats-filter.pod index ac8173c..4fda092 100644 --- a/filters/stats/nbdkit-stats-filter.pod +++ b/filters/stats/nbdkit-stats-filter.pod @@ -25,10 +25,10 @@ number of read, write and trim operations involved: run : \ mkfs ext4 /dev/sda ' - elapsed time: 1.258933 s - read: 254 ops, 0.000326 s, 4.78 MiB, 14.31 GiB/s op, 3.80 MiB/s total - write: 78 ops, 0.167061 s, 32.64 MiB, 195.40 MiB/s op, 25.93 MiB/s total - trim: 33 ops, 0.000304 s, 1.00 GiB, 3289.47 GiB/s op, 813.39 MiB/s total + total: 370 ops, 1.282993 s, 1.04 GiB, 827.29 MiB/s + read: 250 ops, 0.000364 s, 4.76 MiB, 12.78 GiB/s op, 3.71 MiB/s total + write: 78 ops, 0.175715 s, 32.64 MiB, 185.78 MiB/s op, 25.44 MiB/s total + trim: 33 ops, 0.000252 s, 1.00 GiB, 3968.25 GiB/s op, 798.13 MiB/s total flush: 9 ops, 0.000002 s, 0 bytes, 0 bytes/s op, 0 bytes/s total =head1 PARAMETERS diff --git a/filters/stats/stats.c b/filters/stats/stats.c index fbd6b87..0759ceb 100644 --- a/filters/stats/stats.c +++ b/filters/stats/stats.c @@ -125,10 +125,27 @@ print_stat (const stat *st, int64_t usecs) } } +static void +print_totals (uint64_t usecs) +{ + uint64_t ops = pread_st.ops + pwrite_st.ops + trim_st.ops + zero_st.ops + + extents_st.ops + flush_st.ops; + uint64_t bytes = pread_st.bytes + pwrite_st.bytes + trim_st.bytes + + zero_st.bytes; + char *size = humansize (bytes); + char *rate = humanrate (bytes, usecs); + + fprintf (fp, "total: %" PRIu64 " ops, %.6f s, %s, %s/s\n", + ops, usecs / 1000000.0, maybe (size), maybe (rate)); + + free (size); + free (rate); +} + static inline void print_stats (int64_t usecs) { - fprintf (fp, "elapsed time: %.6f s\n", usecs / 1000000.); + print_totals (usecs); print_stat (&pread_st, usecs); print_stat (&pwrite_st, usecs); print_stat (&trim_st, usecs); -- 2.21.0