Profiling your PHP scripts

Before optimizing some code, test its execution time, so first you can see if it's worth and second you will see if your changes gave improvements or not. Performance can be not obvious, so don't trust your intuitions. This snippet comes from php.net website: microtime on www.php.net


function getmicrotime(){
  list($usec, $sec) = explode(" ",microtime());
  return ((float)$usec + (float)$sec);
}
$time_start = getmicrotime();

... code to be profiled here

echo (getmicrotime() - $time_start);