PHP and microbenchmarksAugust 1st, 2008 | by Toomas Römer | |
Microbenchmarks always have to be taken with a grain of salt. I do know that but I happened to stumble upon a PHP optimization tip Avoid overusing function calls.
The test is fairly simple. 4 million iterations of $j = 1 and 4 million iterations of some_func(), a function wrapping the same $j = 1.
The results? Function calls are so expensive that inlined version takes 2 seconds to execute and invoking the function takes 16. 8 time difference, whoah!
The test environment: PHP 5.2.6-2+b1 with Suhosin-Patch 0.9.6.2 (cli) (built: Jul 22 2008 21:03:43) running on a P4@3ghz