Skip to content

Instantly share code, notes, and snippets.

@PatrickTulskie
Created March 1, 2011 16:49
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 PatrickTulskie/da98ab48dbe41986a2aa to your computer and use it in GitHub Desktop.
Save PatrickTulskie/da98ab48dbe41986a2aa to your computer and use it in GitHub Desktop.
user system total real
9.940000 0.090000 10.030000 ( 10.038922)
3.420000 0.000000 3.420000 ( 3.429747)
require 'rubygems'
require 'benchmark'
array = [["banana", "apple"], ["pineapple","beer"]]
Benchmark.bm do |x|
x.report do
1000000.times { array.collect { |sa| sa.collect(&:reverse) } }
end
x.report do
1000000.times { array.collect { |sub_array| sub_array.collect { |subsub_array| subsub_array.reverse } } }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment