Skip to content

Instantly share code, notes, and snippets.

@sgonyea
Created December 7, 2010 21:56
Show Gist options
  • Select an option

  • Save sgonyea/732497 to your computer and use it in GitHub Desktop.

Select an option

Save sgonyea/732497 to your computer and use it in GitHub Desktop.
# MRI
Rehearsal -----------------------------------------------------------
symbol w/ interpolation 1.740000 0.010000 1.750000 ( 1.745346)
string w/ interpolation 1.350000 0.000000 1.350000 ( 1.353597)
symbol 0.200000 0.000000 0.200000 ( 0.207208)
string 0.440000 0.000000 0.440000 ( 0.439890)
-------------------------------------------------- total: 3.740000sec
user system total real
symbol w/ interpolation 1.870000 0.010000 1.880000 ( 1.877624)
string w/ interpolation 1.300000 0.000000 1.300000 ( 1.309572)
symbol 0.210000 0.000000 0.210000 ( 0.205034)
string 0.470000 0.000000 0.470000 ( 0.476345)
gc-begone!
Rehearsal --------------------------------------------------------------------------
symbol w/ interpolation 1.770000 0.010000 1.780000 ( 1.774826)
symbol w/ interpolation and gc-begone! 0.590000 0.000000 0.590000 ( 0.586810)
string w/ interpolation 1.290000 0.000000 1.290000 ( 1.298141)
symbol 0.210000 0.000000 0.210000 ( 0.206038)
string 0.430000 0.000000 0.430000 ( 0.434846)
----------------------------------------------------------------- total: 4.300000sec
user system total real
symbol w/ interpolation 1.740000 0.010000 1.750000 ( 1.739623)
symbol w/ interpolation and gc-begone! 0.600000 0.000000 0.600000 ( 0.604846)
string w/ interpolation 1.280000 0.000000 1.280000 ( 1.285195)
symbol 0.230000 0.000000 0.230000 ( 0.224491)
string 0.490000 0.000000 0.490000 ( 0.496763)
# Rubinius
Rehearsal --------------------------------------------------------------------------
symbol w/ interpolation 0.763277 0.005899 0.769176 ( 0.662442)
symbol w/ interpolation and gc-begone! 0.137618 0.000262 0.137880 ( 0.132575)
string w/ interpolation 0.453309 0.001676 0.454985 ( 0.448123)
symbol 0.039019 0.000073 0.039092 ( 0.036853)
string 0.140208 0.000443 0.140651 ( 0.140450)
----------------------------------------------------------------- total: 1.541784sec
user system total real
symbol w/ interpolation 0.444339 0.001104 0.445443 ( 0.446296)
symbol w/ interpolation and gc-begone! 0.129782 0.000188 0.129970 ( 0.130453)
string w/ interpolation 0.361510 0.000935 0.362445 ( 0.363314)
symbol 0.035721 0.000062 0.035783 ( 0.035923)
string 0.132462 0.000352 0.132814 ( 0.133227)
require 'benchmark'
num1 = "num1"
num2 = "num2"
iters = 1000000
Benchmark.bmbm do |x|
x.report('symbol w/ interpolation') do
iters.times.each do
:"A#{num1}:C#{num2}"
end
end
x.report('symbol w/ interpolation and gc-begone!') do
anti_gc = "A#{num1}:C#{num2}"
iters.times.each do
anti_gc.to_sym
end
end
x.report('string w/ interpolation') do
iters.times.each do
"A#{num1}:C#{num2}"
end
end
x.report('symbol') do
iters.times.each do
:"Hi-There"
end
end
x.report('string') do
iters.times.each do
"Hi-There"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment