Time

Simple benchmarks in PHP

If you’re doing some basic profiling of your PHP scripts, the build-in microtime function can help you make some simple benchmarking fast. Here’s a rough example to show you how it could be used. The doSomething function is the function we want to benchmark. $time = microtime(); $time = explode(' ', $time); $time = $time\[1\] + $time\[0\]; $start = $time; doSomething(); $time = microtime(); $time = explode(' ', $time); $time = $time\[1\] + $time\[0\]; $finish = $time; $total\_time = round(($finish - $start), 6); if ($debug) print ("<p>Processing took approximately $total\_timeseconds</p>");