From: Gavin Sinclair Date: 2003-01-23T23:27:33+09:00 Subject: Re: Single vs double quotes and performance? On Thursday, January 23, 2003, 6:53:11 AM, Daniel wrote: > On Thu, Jan 23, 2003 at 03:40:22AM +0900, E F van de Laar wrote: >> Is my nitpicking going to help me out in the long run or am I just >> waisting my time here. This minor issue has been itching my brain >> for a while now. :) > $ cat single_quotes > 100_000.times { puts 'Hello World' } > $ cat double_quotes > 100_000.times { puts "Hello World" } > $ time ruby single_quotes > [snip] > real 0m22.812s > user 0m2.220s > sys 0m1.660s > $ time ruby double_quotes > real 0m21.614s > user 0m2.100s > sys 0m1.600s > The significant measure is 'user'. You can expect to save 0.1 seconds > after printing 100 thousand strings. I hope you din't mind me nitpicking. In each of those programs, you only define a single string. You are not measuring the time to construct a string with single-vs-double quotes, you are measuring the time to print 100000 already-constructed strings! Perhaps the 0.1 second time difference is explained by the fact that the double-quoted version needs to look for more special characters. But I doubt it. Gavin