formatMS() public static method

Formats the elapsed time as a string.
public static formatMS ( float $time ) : string
$time float
return string
Example #1
0
 /**
  * Runs an empty test to determine the benchmark overhead and run each test once
  */
 private function _warmup()
 {
     $warmup = new Test('warmup', function () {
     });
     $this->_overhead = $warmup->runTest($this->_count);
     // One call each method for init (warmup)
     /** @var Test $test */
     foreach ($this->_tests as $test) {
         $test->runTest(1);
     }
     $this->out('PHP Overhead: ' . 'time=' . Timer::formatMS($this->_overhead['time']) . '; ' . 'memory=' . FS::format($this->_overhead['memory'], 2) . ';' . PHP_EOL);
 }
Example #2
0
 /**
  * @param int $count
  * @return array
  */
 public function runTest($count = 1)
 {
     gc_collect_cycles();
     // Forces collection of any existing garbage cycles
     $this->_profiler->start();
     for ($i = 0; $i < $count; $i++) {
         // Store the result so it appears in memory profiling
         $this->_executeTest();
     }
     $this->_profiler->stop();
     $time = $this->_profiler->getTime();
     $timeOne = $this->_profiler->getTime() / $count;
     $memory = $this->_profiler->getMemory();
     return array('time' => $time, 'time_one' => $timeOne, 'memory' => $memory, 'count' => $count, 'formated' => sprintf("Time: %s/%s; Memory: %s; Count: %s", Timer::formatMS($time), Timer::formatMS($timeOne), FS::format($memory), $count));
 }
Example #3
0
 /**
  * @dataProvider milliSecondsProvider
  * @param string $string
  * @param mixed  $seconds
  */
 public function testSecondsToTimeStringInMillisecond($string, $seconds)
 {
     isSame($string, Timer::formatMS($seconds));
 }