ubench icon indicating copy to clipboard operation
ubench copied to clipboard

Display sub millisecond times

Open mirahost opened this issue 9 years ago • 1 comments

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?

mirahost avatar Apr 04 '16 23:04 mirahost

Actually, this is just as easy to do, if you set raw output to true:

round($Benchmark->getTime(true)*1000,3).'ms'

mirahost avatar Apr 04 '16 23:04 mirahost