Skip to content

Instantly share code, notes, and snippets.

@benpickles
Created June 11, 2009 09:38
Show Gist options
  • Save benpickles/127811 to your computer and use it in GitHub Desktop.
Save benpickles/127811 to your computer and use it in GitHub Desktop.
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')}"
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