Skip to content

Instantly share code, notes, and snippets.

@manveru
Created December 25, 2009 04:33
Show Gist options
  • Save manveru/263507 to your computer and use it in GitHub Desktop.
Save manveru/263507 to your computer and use it in GitHub Desktop.
require 'benchmark'
h = {
:asymbol => :foo,
:astring => 'foo',
'bsymbol' => :bar,
'bsymbol' => 'bar'
}
iterations = 2_000_000
Benchmark.bmbm(20) do |x|
x.report(":asymbol :") { iterations.times{ h[:asymbol] } }
x.report(":astring :") { iterations.times{ h[:astring] } }
x.report("bsymbol :") { iterations.times{ h['bsymbol'] } }
x.report("bstring :") { iterations.times{ h['bstring'] } }
end
jruby-1.4.0: jruby 1.4.0 (ruby 1.8.7 patchlevel 174) (2009-11-02 69fbfa3) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_17) [amd64-java]
Rehearsal -------------------------------------------------------
:asymbol : 0.656000 0.000000 0.656000 ( 0.578000)
:astring : 0.449000 0.000000 0.449000 ( 0.448000)
bsymbol : 0.816000 0.000000 0.816000 ( 0.816000)
bstring : 0.962000 0.000000 0.962000 ( 0.962000)
---------------------------------------------- total: 2.883000sec
user system total real
:asymbol : 0.334000 0.000000 0.334000 ( 0.334000)
:astring : 0.375000 0.000000 0.375000 ( 0.375000)
bsymbol : 0.582000 0.000000 0.582000 ( 0.582000)
bstring : 0.846000 0.000000 0.846000 ( 0.846000)
mput-head: ruby 1.9.2dev (2009-12-24 trunk 26168) [x86_64-linux]
Rehearsal -------------------------------------------------------
:asymbol : 0.420000 0.000000 0.420000 ( 0.414727)
:astring : 0.400000 0.000000 0.400000 ( 0.413010)
bsymbol : 1.110000 0.000000 1.110000 ( 1.134691)
bstring : 1.250000 0.000000 1.250000 ( 1.308274)
---------------------------------------------- total: 3.180000sec
user system total real
:asymbol : 0.400000 0.000000 0.400000 ( 0.416389)
:astring : 0.420000 0.000000 0.420000 ( 0.416553)
bsymbol : 1.090000 0.000000 1.090000 ( 1.140650)
bstring : 1.260000 0.000000 1.260000 ( 1.294122)
rbx-1.0.0-rc1: rubinius 1.0.0-rc1 (1.8.7 release 2009-11-25) [x86_64-unknown-linux-gnu]
Rehearsal -------------------------------------------------------
:asymbol : 2.547505 0.000000 2.547505 ( 2.547515)
:astring : 3.576921 0.000000 3.576921 ( 3.576965)
bsymbol : 3.621407 0.000000 3.621407 ( 3.621463)
bstring : 2.913508 0.000000 2.913508 ( 2.913561)
--------------------------------------------- total: 12.659341sec
user system total real
:asymbol : 2.976471 0.000000 2.976471 ( 2.976492)
:astring : 3.521423 0.000000 3.521423 ( 3.521699)
bsymbol : 4.192677 0.000000 4.192677 ( 4.192712)
bstring : 3.704274 0.000000 3.704274 ( 3.704298)
ree-1.8.7-2009.10: ruby 1.8.7 (2009-06-12 patchlevel 174) [x86_64-linux], MBARI 0x6770, Ruby Enterprise Edition 2009.10
Rehearsal -------------------------------------------------------
:asymbol : 0.690000 0.010000 0.700000 ( 0.778265)
:astring : 0.660000 0.020000 0.680000 ( 0.695333)
bsymbol : 1.380000 0.000000 1.380000 ( 1.913282)
bstring : 1.630000 0.050000 1.680000 ( 1.760063)
---------------------------------------------- total: 4.440000sec
user system total real
:asymbol : 0.680000 0.000000 0.680000 ( 0.700407)
:astring : 0.700000 0.000000 0.700000 ( 0.717442)
bsymbol : 1.420000 0.020000 1.440000 ( 1.493170)
bstring : 1.640000 0.000000 1.640000 ( 2.012437)
ruby-1.8.6-p383: ruby 1.8.6 (2009-08-04 patchlevel 383) [x86_64-linux]
Rehearsal -------------------------------------------------------
:asymbol : 0.760000 0.000000 0.760000 ( 0.989002)
:astring : 0.730000 0.000000 0.730000 ( 0.962356)
bsymbol : 1.600000 0.010000 1.610000 ( 1.854672)
bstring : 1.730000 0.000000 1.730000 ( 1.997822)
---------------------------------------------- total: 4.830000sec
user system total real
:asymbol : 0.730000 0.000000 0.730000 ( 0.754034)
:astring : 0.750000 0.010000 0.760000 ( 1.007879)
bsymbol : 1.640000 0.010000 1.650000 ( 2.478432)
bstring : 1.760000 0.000000 1.760000 ( 2.296430)
ruby-1.8.7-p174: ruby 1.8.7 (2009-06-12 patchlevel 174) [x86_64-linux]
Rehearsal -------------------------------------------------------
:asymbol : 0.570000 0.000000 0.570000 ( 0.640560)
:astring : 0.560000 0.000000 0.560000 ( 0.807316)
bsymbol : 1.570000 0.000000 1.570000 ( 1.697235)
bstring : 1.720000 0.010000 1.730000 ( 2.223992)
---------------------------------------------- total: 4.430000sec
user system total real
:asymbol : 0.550000 0.000000 0.550000 ( 0.614088)
:astring : 0.570000 0.000000 0.570000 ( 0.605778)
bsymbol : 1.570000 0.000000 1.570000 ( 1.866750)
bstring : 1.720000 0.010000 1.730000 ( 2.213083)
ruby-1.9.1-p243: ruby 1.9.1p243 (2009-07-16 revision 24175) [x86_64-linux]
Rehearsal -------------------------------------------------------
:asymbol : 0.340000 0.000000 0.340000 ( 0.431982)
:astring : 0.370000 0.000000 0.370000 ( 0.395917)
bsymbol : 1.170000 0.000000 1.170000 ( 1.381670)
bstring : 1.420000 0.000000 1.420000 ( 1.558583)
---------------------------------------------- total: 3.300000sec
user system total real
:asymbol : 0.360000 0.000000 0.360000 ( 0.383138)
:astring : 0.320000 0.000000 0.320000 ( 0.384652)
bsymbol : 1.210000 0.010000 1.220000 ( 1.495746)
bstring : 1.390000 0.000000 1.390000 ( 1.753136)
ruby-1.9.1-p376: ruby 1.9.1p376 (2009-12-07 revision 26041) [x86_64-linux]
Rehearsal -------------------------------------------------------
:asymbol : 0.400000 0.000000 0.400000 ( 0.457230)
:astring : 0.380000 0.000000 0.380000 ( 0.457623)
bsymbol : 1.360000 0.000000 1.360000 ( 1.772202)
bstring : 1.610000 0.000000 1.610000 ( 1.759956)
---------------------------------------------- total: 3.750000sec
user system total real
:asymbol : 0.390000 0.000000 0.390000 ( 0.411482)
:astring : 0.360000 0.000000 0.360000 ( 0.415051)
bsymbol : 1.350000 0.000000 1.350000 ( 1.528600)
bstring : 1.610000 0.000000 1.610000 ( 1.705505)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment