From: Vincent Fourmond Date: 2007-01-10T06:17:22+09:00 Subject: Re: String performance Gavin Kistner wrote: > From: Vincent Fourmond >> user system total real >> 0.010000 0.000000 0.010000 ( 0.009087) >> 0.010000 0.000000 0.010000 ( 0.008774) >> 0.000000 0.000000 0.000000 ( 0.004621) > > Perhaps your machine is more deterministic than mine, but successive > runs of that benchmark (and using #bmbm to be safer about the > measurement) sometimes show 'a' faster than "a", sometimes slower. The thing is they are rigourosly equivalents. As soon as the program is parsed, they are represented exactly as the same objects, a String. So they are the same, that's why you get around the same processing times. Moreover, it is normal that interpolation is faster, because it involves only evaluation of x as a String and string copy, whereas addition involves two method calls (+ and +), which are rather expensive (at least more than a string copy for such small strings). Cheers, Vince -- Vincent Fourmond, PhD student http://vincent.fourmond.neuf.fr/