summaryrefslogtreecommitdiff
path: root/benchmark
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-06 21:47:56 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-06 21:47:56 +0000
commit789b288d10f287055c657dc78d1826f5dba6dd0c (patch)
treec6246a555c2601ba87c7fffc644e8d6596bec092 /benchmark
parent0e7da28c98711f807b86900f37bd5bed22922dd5 (diff)
* benchmark/driver.rb: Add difference column to report that averages
across all runs of a benchmark. [Ruby 1.9 - Feature #4982] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/driver.rb21
1 files changed, 20 insertions, 1 deletions
diff --git a/benchmark/driver.rb b/benchmark/driver.rb
index c38c4fb..7dab292 100644
--- a/benchmark/driver.rb
+++ b/benchmark/driver.rb
@@ -90,6 +90,10 @@ class BenchmarkDriver
end
end
+ def average results
+ results.inject(:+) / results.length
+ end
+
def show_results
output
@@ -109,7 +113,10 @@ class BenchmarkDriver
output "minimum results in each #{@repeat} measurements."
end
- output "name\t#{@execs.map{|(e, v)| v}.join("\t")}"
+ difference = "\taverage difference" if @execs.length == 2
+ total_difference = 0
+
+ output "name\t#{@execs.map{|(e, v)| v}.join("\t")}#{difference}"
@results.each{|v, result|
rets = []
s = nil
@@ -129,8 +136,20 @@ class BenchmarkDriver
end
rets << sprintf("%.3f", r)
}
+
+ if difference
+ diff = average(result.last) - average(result.first)
+ total_difference += diff
+ rets << sprintf("%.3f", diff)
+ end
+
output "#{v}#{s}\t#{rets.join("\t")}"
}
+
+ if difference and @verbose
+ output '-----------------------------------------------------------'
+ output "average total difference is #{total_difference}"
+ end
end
def files