On 9/25/06, Christian Neukirchen <chneukirchen / gmail.com> wrote: > James Edward Gray II <james / grayproductions.net> writes: > > > On Sep 25, 2006, at 12:03 PM, Rich Morin wrote: > > > >> Use '' by default: > >> > >> - It's less work for the interpreter. > > > > What makes you say this? > > > > #!/usr/bin/env ruby -w > > > > require "benchmark" > > > > TESTS = 1_000_000 > > Benchmark.bmbm(10) do |results| > > results.report("double:") { TESTS.times { "James" } } > > results.report("single:") { TESTS.times { 'James' } } > > end > > You really should compare the parse-trees of these before even trying > to benchmark it that way... Du hast ist recht! 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$ -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ IPMS/USA Region 12 Coordinator http://ipmsr12.denhaven2.com/ Visit the Project Mercury Wiki Site http://www.mercuryspacecraft.com/