public
Created

  • Download Gist
temp.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
require "rubygems"
require "rbench"
 
RBench.run(1_000_000) do
column :time
 
report "block" do
times {[1,2,3,4,5].map {|v| v.to_s}}
end
 
report "symbol2proc" do
times {[1,2,3,4,5].map(&:to_s)}
end
end
 
# Results on 1.9.2:
# TIME |
# -----------------------------
# block 0.234 |
# symbol2proc 0.195 |
#
# Results on 1.8.7
#
# TIME |
# -----------------------------
# block 0.240 |
# symbol2proc 0.238 |

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.