hrtime()¶
hrtime() is a native PHP function and an PECL extension. As a function, hrtime() returns the high precision time of the system.
HRT represents an acronym of High Resolution Time.
The time is of high precision, but counted from an arbitrary point of time: the value of this function is in calculating differences between two hrtime() calls, rather than the obtained value.
hrtime() is a good replacement for microtime().
<?php
$timeStart = hrtime(true);
// Sleep some time
usleep(100);
$timeEnd = hrtime(true);
$time = $timeEnd - $timeStart;
echo "Slept for $time micro-seconds\n";
?>
See also PHP hrtime Function.
Related : microtime(), Micro-second, sleep