CakeFest 2024: The Official CakePHP Conference

HRTime\StopWatch::getElapsedTime

(PECL hrtime >= 0.4.3)

HRTime\StopWatch::getElapsedTimeПолучить суммарное прошедшее время всех интервалов

Описание

public HRTime\StopWatch::getElapsedTime(int $unit = ?): float

Возвращает суммарное прошедшее время всех интервалов.

Список параметров

unit

Единица времени, заданная одной из констант HRTime\Unit. По умолчанию HRTime\Unit::SECOND.

Возвращаемые значения

Возвращает значение типа float, равное прошедшему времени.

add a note

User Contributed Notes 1 note

up
-1
j_jaberi at yahoo dot com
4 years ago
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
To Top