ubench
ubench copied to clipboard
Display sub millisecond times
The readableElapsedTime function supports a $round parameter, but this isn't passed to the ms output. If this is passed and the $format is removed it will work with sub millisecond times
public static function readableElapsedTime($microtime, $format = null, $round = 4)
{
if (is_null($format)) {
$format = '%.3f%s';
}
if ($microtime >= 1) {
$unit = 's';
$time = round($microtime, $round);
} else {
$unit = 'ms';
$time = round($microtime*1000, $round);
// $format = preg_replace('/(%.[\d]+f)/', '%d', $format);
}
return sprintf($format, $time, $unit);
}
Previously we would get results as 0ms, now they say 0.234ms
Would you consider implementing this?
Actually, this is just as easy to do, if you set raw output to true:
round($Benchmark->getTime(true)*1000,3).'ms'