Skip to content

Instantly share code, notes, and snippets.

@ELLIOTTCABLE
Forked from anonymous/results
Created August 2, 2008 13:04
Show Gist options
  • Save ELLIOTTCABLE/3734 to your computer and use it in GitHub Desktop.
Save ELLIOTTCABLE/3734 to your computer and use it in GitHub Desktop.
require 'rubygems' and require 'activesupport' if RUBY_VERSION == "1.8.6"
p RUBY_VERSION
p RUBY_RELEASE_DATE
require "benchmark"
SIZE = 1_000
TIMES = 10_000
RANGE = (1..SIZE)
print " "
Benchmark.bm do |bm|
bm.report " block" do
TIMES.times do
RANGE.map { |n| n.to_s }
end
end
bm.report "symbol" do
TIMES.times do
RANGE.map &:to_s
end
end
end
"1.8.6"
"2008-03-03"
user system total real
block 35.650000 0.050000 35.700000 ( 35.717756)
symbol106.290000 3.940000 110.230000 (111.735975)
"1.8.6"
"2008-03-03"
user system total real
block 35.230000 0.020000 35.250000 ( 35.282963)
symbol 99.980000 0.120000 100.100000 (100.431351)
"1.9.0"
"2007-12-25"
user system total real
block 13.210000 0.000000 13.210000 ( 13.221047)
symbol 11.060000 0.020000 11.080000 ( 11.099965)
"1.9.0"
"2007-12-25"
user system total real
block 12.640000 0.010000 12.650000 ( 12.671435)
symbol 11.100000 0.000000 11.100000 ( 11.101745)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment