Created
June 11, 2009 09:38
-
-
Save benpickles/127811 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
require 'benchmark' | |
Dir.mkdir('results') unless File.exists?('results') | |
$stdout = File.new("results/#{Process.pid}.txt", 'w') | |
puts "Start: #{Time.now.strftime('%H:%M:%S')}" | |
array = (1..1000000).map { rand }; nil | |
Benchmark.bmbm do |x| | |
x.report('sort!') { array.dup.sort! } | |
x.report('sort') { array.dup.sort } | |
end | |
puts "Finish: #{Time.now.strftime('%H:%M:%S')}" | |
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
echo Running $1 times... | |
for ((i = 1; i <= $1; i++)) do | |
ruby bench.rb & | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment