- microtime: documentation ( source)
<?php
$start = microtime(true);
while (microtime(true) != $start + 1); // Wait a second to start up
$loops = 10;
$avg = 0;
for ($i = 0; $i < $loops; $i++) {
$start = microtime(true);
for ($c = 0; $c < 1000; $c++) { // the 1000 may vary depending on the function
}
$end = microtime(true);
echo "Take $i: " . ($end-$start) . "s\n";
$avg *= $i;
$avg += $end - $start;
$avg /= $i + 1;
}
echo "Average: " . $avg . "s\n";