Life is many a grand thing and with information flowing freer than ever, the infinite complexities of the universe are slowly unravelling right now. – Luka Zabkar
PHP Benchmark: Calculate loop length in advance
As shown and tested on www.phpbench.com, calculating the size of your loop in advance can be a huge performance boost. Makes sense of course, still the nature of PHP could lead you to believe that there’s an optimization in place, even if there’s little sound logic supporting it.
1 2 3 4 | // Faster for ($i=0; $i < $size; $i++) // Slower for ($i=0; $i < sizeOf($x); $i++) |
