He offers a lot of benchmarking data to prove which methods of coding are faster etc.
The PHP Benchmark
Results 1 to 2 of 2
Thread: [PHP] Interesting site.
- 18 Nov. 2009 10:40pm #1
- Age
- 30
- Join Date
- Nov. 2009
- Location
- Anaheim, California
- Posts
- 1,065
- Reputation
- 99
- LCash
- 500.00
[PHP] Interesting site.
- 19 Nov. 2009 03:06am #2
This is very nice. An odd thing I noticed is:
+131% echo 'aaaaaaa'.'aaaaaaa'.'aaaaaaa'.'aaaaaaa' Total time: 114µs
+329% echo 'aaaaaaa','aaaaaaa','aaaaaaa','aaaaaaa' Total time: 286µs
I'm fairly certain he typo'd those backwards. As he stated:The one small thing to notice is that when using a comma to separate items whilst using the echo function, items run slightly faster.
+507% $a = 'aaaaaaa'; echo 'aaaaaaa'.$a.'aaaaaaa'.$a; Total time: 441µs
+475% $a = 'aaaaaaa'; echo 'aaaaaaa',$a,'aaaaaaa',$a; Total time: 413µs
The comma runs faster.
The reason for this is that when you echo 'string' . 'string2', the two strings have to be concatenated before being output, whereas echo 'string', 'string2' will output them consecutively with no extra calculations needed.
And the reason echo is faster than print is because print returns 1 (or true, IDR) on success and 0 (or false) on failure. Whereas echo just outputs it and returns nothing. The extra time it takes to return the value causes print to run slower. And since 99.9999999999999...% of scripts don't check or use the return value of print, it's much better to use echo.