CKTIS / PHP
hrtime()
Mide intervalos con un reloj monótono de origen arbitrario.
Versión: PHP 8.4; repository runtime, production runtime not attested
Sintaxis
hrtime(bool $as_number = false): array|int|float|falseMide intervalos con un reloj monótono de origen arbitrario. El par contiene segundos enteros y nanosegundos restantes. Con true obtiene el total en nanosegundos como int en 64 bits o float en 32 bits. Si falla, devuelve false.
Firma
hrtime(bool $as_number = false): array|int|float|false
Salida del ejemplo
[true,2,true]
Ejemplos
<?php
$start=hrtime(true); $pair=hrtime(); $end=hrtime(true);
echo json_encode([$end >= $start,count($pair),$pair[1] >= 0 && $pair[1] < 1000000000]);
Resultado
[true,2,true]