On Sat, Jul 29, 2006 at 01:04:53PM -0600, Chad Perrin wrote:
Curiosity got the better of me, so I did a quick, unscientific benchmark using the unix time utility. Results, with script output cut out, on a script that prints "foo bar" 1499 times, once with comma separation, once with string concatenation, and once with a single interpolated string:
$ time php -f comma.php real 0m0.546s user 0m0.151s sys 0m0.070s
$ time php -f concat.php real 0m0.351s user 0m0.173s sys 0m0.025s
$ time php -f interp.php real 0m0.286s user 0m0.108s sys 0m0.025s
. . . and just for the sake of completeness, I decided to run the interpolation test with print instead of echo to double-check my belief that echo is faster. It seems to actually be roughly equivalent (execution times returned by the time utility vary by greater than the differences between interp.php and print.php). Print, of course, doesn't allow the comma syntax, but since it's the slowest I don't think that's really a problem -- though it can be formatted in a slightly less obnoxious-looking manner than concatenation. Very slightly.
$ time php -f print.php real 0m0.285s user 0m0.101s sys 0m0.032s