Using Benchmarks with simple code
If you want to test a particular aspect of your code without having to worry about the HTTP overhead, you can benchmark using the microtime(), which returns the current time accurate to the microsecond as a string. The following function will convert it into a number suitable for calculations.
function getmicrotime()
{
list($usec, $sec) = explode(” “,microtime());
return ((float)$usec + (float)$sec);
}
$time = getmicrotime();
#
# benchmark code here
#
echo “
Time elapsed: “,getmicrotime() - $time, ” seconds”;
