Skip to content

Display sub millisecond times #3

@mirahost

Description

@mirahost

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions