Created
January 14, 2009 20:03
-
-
Save bmabey/47040 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
spec_commands = {"1.1.12" => "spec", "#does_not_match? version" => "~/p/ruby/rspec/bin/spec"} | |
base_line = "1.1.12" | |
number_of_runs = ENV['NUMBER_OF_RUNS'] || 50 | |
class Array | |
def average | |
@average ||= self.inject{|sum,v| sum + v} / size.to_f | |
end | |
end | |
run_results = {} | |
totals = {} | |
spec_commands.each do |version, bin| | |
command = "#{bin} #{ARGV.join(' ')}" | |
puts "Running the spec #{version} #{number_of_runs} times: #{command}" | |
run_results[version] = [] | |
number_of_runs.times do |i| | |
print "." | |
STDOUT.flush | |
`#{command}` =~ /Finished in (.+) seconds/ | |
run_results[version] << $1.to_f | |
end | |
puts "" | |
end | |
puts "Average Run Time" | |
spec_commands.each do |version, _| | |
min, max = [run_results[base_line].average, run_results[version].average].sort | |
percentage = ((max - min) / min) * 100.0 | |
diff = (min == run_results[version].average) ? "faster" : "slower" | |
puts "#{version} - #{run_results[version].average} seconds (#{percentage}% #{diff} than #{base_line})" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe "Truth" do | |
5000.times do |i| | |
it "should not be false" do | |
true.should_not be_false | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment