HRTime\StopWatch::getElapsedTime
(PECL hrtime >= 0.4.3)
HRTime\StopWatch::getElapsedTime — Get elapsed time for all intervals.
Описание
public float HRTime\StopWatch::getElapsedTime
([ integer
$unit
] )Get elapsed time for all the previously closed intervals.
Список параметров
-
unit
-
Time unit represented by a HRTime\Unit constant. Default is HRTime\Unit::SECOND.
Возвращаемые значения
Returns float indicating elapsed time.
Коментарии
As not mentioned, if used with invalid unit value, it uses default one:
<?php
$stopWatch = new HRTime\StopWatch();
$stopWatch->start();
for($i=0; $i<10000000; $i++);
$stopWatch->stop();
echo $stopWatch->getElapsedTime(-1) . ' - ' .
$stopWatch->getElapsedTime(0) . ' - ' .
$stopWatch->getElapsedTime(1) . ' - ' .
$stopWatch->getElapsedTime(2) . ' - ' .
$stopWatch->getElapsedTime(3) . ' - ' .
$stopWatch->getElapsedTime(4);
?>
Outputs soething like:
0.11936771 - 0.11936771 - 119.36771 - 119367.71 - 119367710 - 0.11936771