[Solved] How to benchmark code to see which runs faster

To benchmark code, you can use microtime() http://php.net/manual/en/function.microtime.php <?php echo ‘modify: ‘; $time = microtime(1); for ($x = 0; $x < 10000; $x++) { $datetime = new DateTime(‘2013-01-29’); $datetime->modify(‘+1 day’); } echo $datetime->format(‘Y-m-d H:i:s’); $end = microtime(1); $time = $end – $time; echo $time . “\n”; echo ‘interval: ‘; $time = microtime(1); for ($x = … Read more