From 9f93df03137616cadadbd7ec1187fe183016536b Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 28 Jan 2015 17:29:33 +0100 Subject: readtest: calculate running average and stddev --- tools/readtest.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/readtest.c b/tools/readtest.c index 00b761a654..0f2ae7ddd6 100644 --- a/tools/readtest.c +++ b/tools/readtest.c @@ -143,6 +143,9 @@ main (int argc, char* argv[]) uint64_t _read = 0; double max_elapsed = 0; double total_time = 0; + double var_m = 0; + double var_s = 0; + uint64_t cnt = 0; while (1) { gint64 before; @@ -165,6 +168,15 @@ main (int argc, char* argv[]) total_time += elapsed; + ++cnt; + if (max_elapsed == 0) { + var_m = elapsed; + } else { + const double var_m1 = var_m; + var_m = var_m + (elapsed - var_m) / (double)(cnt); + var_s = var_s + (elapsed - var_m) * (elapsed - var_m1); + } + if (elapsed > max_elapsed) { max_elapsed = elapsed; } @@ -173,12 +185,13 @@ main (int argc, char* argv[]) out: if (max_elapsed > 0 && total_time > 0) { + double stddev = cnt > 1 ? sqrt(var_s / ((double)(cnt-1))) : 0; double bandwidth = ((nfiles * _read)/1048576.0) / (total_time/1000000.0); double min_throughput = ((nfiles * block_size)/1048576.0) / (max_elapsed/1000000.0); printf ("# Min: %.4f MB/sec Avg: %.4f MB/sec || Max: %.3f sec \n", min_throughput, bandwidth, max_elapsed/1000000.0); printf ("# Max Track count: %d @ 48000SPS\n", (int) floor(1048576.0 * bandwidth / (4 * 48000.))); printf ("# Sus Track count: %d @ 48000SPS\n", (int) floor(1048576.0 * min_throughput / (4 * 48000.))); - printf ("%d %.4f %.4f %.4f\n", block_size, min_throughput, bandwidth, max_elapsed/1000000.0); + printf ("%d %.4f %.4f %.4f %.5f\n", block_size, min_throughput, bandwidth, max_elapsed/1000000.0, stddev/1000000.0); } return 0; -- cgit v1.2.3