readtest: calculate running average and stddev
This commit is contained in:
parent
07e53fc2e7
commit
9f93df0313
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue