You are here

public static function PHP_Timer::secondsToTimeString in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpunit/php-timer/src/Timer.php \PHP_Timer::secondsToTimeString()

Formats the elapsed time as a string.

Parameters

float $time:

Return value

string

2 calls to PHP_Timer::secondsToTimeString()
PHP_Timer::timeSinceStartOfRequest in vendor/phpunit/php-timer/src/Timer.php
Formats the elapsed time since the start of the request as a string.
PHP_TimerTest::testSecondsToTimeString in vendor/phpunit/php-timer/Tests/TimerTest.php
@covers PHP_Timer::secondsToTimeString @dataProvider secondsProvider

File

vendor/phpunit/php-timer/src/Timer.php, line 61

Class

PHP_Timer
Utility class for timing.

Code

public static function secondsToTimeString($time) {
  $ms = round($time * 1000);
  foreach (self::$times as $unit => $value) {
    if ($ms >= $value) {
      $time = floor($ms / $value * 100.0) / 100.0;
      return $time . ' ' . ($time == 1 ? $unit : $unit . 's');
    }
  }
  return $ms . ' ms';
}