summaryrefslogtreecommitdiff
path: root/tools/readtest.c
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2015-01-28 17:29:33 +0100
committerRobin Gareus <robin@gareus.org>2015-01-28 17:29:33 +0100
commit9f93df03137616cadadbd7ec1187fe183016536b (patch)
treefdacc1f8d5b8f952d9985cddd20b020ad05ddeed /tools/readtest.c
parent07e53fc2e77462e2e5029dc4e7ac1437c7f6a861 (diff)
readtest: calculate running average and stddev
Diffstat (limited to 'tools/readtest.c')
-rw-r--r--tools/readtest.c15
1 files changed, 14 insertions, 1 deletions
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;