Testing is one of common task for programmer. In every development phase, testing is need to be done before moving to next phase. There are a lot of testing technique. One of them is benchmarking, to test script/code performance. Benchmark test result can be used to optimize the code/script.
As in PHP you can get how long your server took to parse and execute your code. Here is the simple snippet code to get the execution time:
$start = microtime(true); // Script you want to test here usleep(200000); // sleep 2 seconds $end = microtime(true); $r = round($end - $start,4); echo '<strong>Execution Time</strong>: '.$r.' seconds<br />';
This simple code will help you discover bottlenecks in your script – there are a load of things you can do to optimize your code/script; and I find that using functions as above don’t add extra load to your script.