Created
May 23, 2011 21:10
-
-
Save denisdefreyne/987617 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' | |
puts "Setting up..." | |
array = [] | |
10000.times { |i| array << i } | |
puts "Running..." | |
Benchmark.bmbm do |bm| | |
bm.report('.reverse_each') do | |
10000.times { array.reverse_each { |i| } } | |
end | |
bm.report('.reverse.each') do | |
10000.times { array.reverse.each { |i| } } | |
end | |
end | |
# Setting up... | |
# Running... | |
# Rehearsal ------------------------------------------------- | |
# .reverse_each 11.520000 0.020000 11.540000 ( 11.528721) | |
# .reverse.each 11.840000 0.070000 11.910000 ( 11.910495) | |
# --------------------------------------- total: 23.450000sec | |
# | |
# user system total real | |
# .reverse_each 11.620000 0.020000 11.640000 ( 11.632423) | |
# .reverse.each 11.800000 0.050000 11.850000 ( 11.844841) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment