Wrap text
|
|
require 'benchmark'
class Symbol
def to_proc
Proc.new { |*args| args.shift.__send__(self, *args) }
end
end
BIG_ARRAY = [:abcdef] * 10
Benchmark.bmbm do |x|
x.report do
BIG_ARRAY.map(&:to_s)
end
x.report do
BIG_ARRAY.map { |e| e.to_s }
end
end
$ ruby -v
ruby 1.8.6 (2008-03-03 patchlevel 114) [i686-darwin9.2.0]
$ ruby iter.rb
Rehearsal ------------------------------------
0.000000 0.000000 0.000000 ( 0.000037)
0.000000 0.000000 0.000000 ( 0.000014)
--------------------------- total: 0.000000sec
user system total real
0.000000 0.000000 0.000000 ( 0.000030)
0.000000 0.000000 0.000000 ( 0.000014)
|