Time elapsed
<?php
/**
* Inline profiler :)
*
* $time = s();
* for ($i = 0; $i < 100000; $i++) {
* $j = $i + 1;
* }
* s($time);
*
* @param bool|int $time
* @return mixed
*/
function s($time = false)
{
if ($time) {
echo number_format(microtime(true) - $time, 2) . 's';
} else {
return microtime(true);
}
}
$t = s();
for ($i = 0; $i < 100000; $i++) {
$j = $i + 1;
}
s($t);