Skip to content

Instantly share code, notes, and snippets.

@eregon
Forked from enebo/perf1.rb
Created July 6, 2012 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eregon/3062256 to your computer and use it in GitHub Desktop.
Save eregon/3062256 to your computer and use it in GitHub Desktop.
Perfer.session "Array#sort" do |s|
s.bench "Array#sort" do |b|
b.description "Yeah sorting"
b.bench_code do |n|
ary = Array.new(n) { rand(n) }
b.measure do # mmh, should not be b here ideally
ary.sort
end
end
end
s.bench "Array#sort!" do |n|
b.description "Yeah sorting!"
b.bench_code do |n|
ary = Array.new(n) { rand(n) }
b.measure do
ary.sort!
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment