Don Alexander Eckford's microtime()
The following is an example of microtime() function
This script took: 0.00378 seconds to execute
This script took: 0.00378 seconds to execute
<?php
include('includes/header.php');
error_reporting(E_ALL); // set error reporting to all
echo("<h1> Don Alexander Eckford's microtime()</h1>");
echo('<h2>The following is an example of microtime() function</h2>');
// start clock
$starttime = microtime();
$startarray = explode(" ", $starttime);
$starttime = $startarray[1] + $startarray[0];
// do 1 million counts
for ($i=1; $i < 1000000; $i++)
{
$a = $i;
}
// stop clock
$endtime = microtime();
$endarray = explode(" ", $endtime);
$endtime = $endarray[1] + $endarray[0];
$totaltime = $endtime - $starttime;
$totaltime = round($totaltime,5); // round to five places
// show time elapsed
echo("<p>This script took: $totaltime seconds to execute</p>");
include('includes/footer.php');
?>