"Rick DeNatale" <rick.denatale / gmail.com> writes: >> You really should compare the parse-trees of these before even trying >> to benchmark it that way... > > Du hast ist recht! Drop the "ist". > Any differences due to parsing are going to happen when the source > code is parsed, which will happen before the benchmark is run. > > I believe that this gives a better handle on the relative parsing > overhead, there doesn't seem to be much difference. > > rick@frodo:/public/rubyscripts$ cat slbench.rb > require 'benchmark' > > TESTS = 1_000_000 > Benchmark.bmbm(10) do |results| > results.report("double:") {TESTS.times{eval("\"James\"")}} > results.report("single:") {TESTS.times{eval('\'James\'')}} > end > rick@frodo:/public/rubyscripts$ ruby slbench.rb > Rehearsal --------------------------------------------- > double: 31.990000 1.030000 33.020000 ( 55.318747) > single: 32.080000 1.120000 33.200000 ( 55.743170) > ----------------------------------- total: 66.220000sec > > user system total real > double: 32.160000 1.040000 33.200000 ( 56.097062) > single: 32.150000 1.090000 33.240000 ( 53.597692) > rick@frodo:/public/rubyscripts$ And now the difference gets lost in noise because the strings aren't long enough. :-) In the end, it doesn't matter. > Rick DeNatale -- Christian Neukirchen <chneukirchen / gmail.com> http://chneukirchen.org