Skip to content

Instantly share code, notes, and snippets.

@norman
Created August 14, 2010 14:13
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 norman/524333 to your computer and use it in GitHub Desktop.
Save norman/524333 to your computer and use it in GitHub Desktop.
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 |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment