Skip to content

Commit

Permalink
* benchmark/driver.rb: Add difference column to report that averages
Browse files Browse the repository at this point in the history
	  across all runs of a benchmark.  [Ruby 1.9 - Feature ruby#4982]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
drbrain committed Jul 6, 2011
1 parent 0e7da28 commit 789b288
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Thu Jul 7 06:46:12 2011 Eric Hodel <[email protected]>

* 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 <[email protected]>

* lib/rubygems.rb: Reduce requires to improve `make benchmark`.
Expand Down
21 changes: 20 additions & 1 deletion benchmark/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ def initialize execs, dir, opt = {}
end
end

def average results
results.inject(:+) / results.length
end

def show_results
output

Expand All @@ -109,7 +113,10 @@ def show_results
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
Expand All @@ -129,8 +136,20 @@ def show_results
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
Expand Down

0 comments on commit 789b288

Please sign in to comment.