1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
drbrain 2011-07-06 21:47:56 +00:00
parent 0e7da28c98
commit 789b288d10
2 changed files with 25 additions and 1 deletions

View file

@ -1,3 +1,8 @@
Thu Jul 7 06:46:12 2011 Eric Hodel <drbrain@segment7.net>
* benchmark/driver.rb: Add difference column to report that averages
across all runs of a benchmark. [Ruby 1.9 - Feature #4982]
Thu Jul 7 06:19:38 2011 Eric Hodel <drbrain@segment7.net>
* lib/rubygems.rb: Reduce requires to improve `make benchmark`.

View file

@ -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