diff options
Diffstat (limited to 'src/runtest')
-rwxr-xr-x | src/runtest | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/src/runtest b/src/runtest index 33322b1..7c8885c 100755 --- a/src/runtest +++ b/src/runtest @@ -17,7 +17,13 @@ my $drop_caches; # Drop system disk caches before each run. my $log_file; # Name of the log file. sub runtest { - my ($t_total, $t_open, $t_loop) = (0,0,0); + use constant { + TOTAL => 0, + OPEN => 1, + LOOP => 2 + }; + my @times = (0,0,0); + my @stddev = (0,0,0); my $n; for ($n = 0; $n < $nsamples; $n++) { @@ -40,9 +46,13 @@ sub runtest { close PH; if (@inbuf == 3) { - $t_total += $inbuf[0]; - $t_open += $inbuf[1]; - $t_loop += $inbuf[2]; + $times[TOTAL] += $inbuf[TOTAL]; + $times[OPEN] += $inbuf[OPEN]; + $times[LOOP] += $inbuf[LOOP]; + + $stddev[TOTAL] += $inbuf[TOTAL] ** 2; + $stddev[OPEN] += $inbuf[OPEN] ** 2; + $stddev[LOOP] += $inbuf[LOOP] ** 2; } else { while (my $s = shift(@inbuf)) { print "$s\n"; @@ -50,7 +60,11 @@ sub runtest { die "no timing info\n"; } } - return ($t_total/$nsamples, $t_open/$nsamples, $t_loop/$nsamples) + for (my $i = 0; $i < @times; $i++) { + $times[$i] /= $nsamples; + $stddev[$i] = sqrt($stddev[$i] / $nsamples - $times[$i] ** 2); + } + return (@times, @stddev); } GetOptions( @@ -63,7 +77,7 @@ GetOptions( unless (-x $drop_caches) { print STDERR <<EOT; $0: the option --drop-caches (-d) requires that the program $drop_caches -be built, be owned by root, and have the setuid bit set (or the tests be +be built, owned by root, and have the setuid bit set (or the tests be run as root). Please, make sure that this is the case and rerun the runtest utility. EOT @@ -90,8 +104,11 @@ if ($log_file) { } for (my $c = $c_init; $c <= $c_final; $c += $c_step) { - my ($t_total, $t_open, $t_loop) = runtest(@ARGV, '-c', $c); - printf LOG "%d %.6f %.6f %.6f\n", $c, $t_total, $t_open, $t_loop; + printf LOG "%d ", $c; + foreach my $t (runtest(@ARGV, '-c', $c)) { + printf LOG " %.6f", $t; + } + print LOG "\n"; } |