1.2.1517. ext/hrtime

High resolution timing Extension.

The HRTime extension implements a high resolution StopWatch class. It uses the best possible API on different platforms which brings resolution up to nanoseconds. It also makes possible to implement a custom stopwatch using low level ticks delivered by the underlaying system.

<?php

$c = new HRTime\StopWatch;

$c->start();
/* measure this code block execution */
for ($i = 0; $i < 1024*1024; $i++);
$c->stop();
$elapsed0 = $c->getLastElapsedTime(HRTime\Unit::NANOSECOND);

/* measurement is not running here*/
for ($i = 0; $i < 1024*1024; $i++);

$c->start();
/* measure this code block execution */
for ($i = 0; $i < 1024*1024; $i++);
$c->stop();
$elapsed1 = $c->getLastElapsedTime(HRTime\Unit::NANOSECOND);

$elapsed_total = $c->getElapsedTime(HRTime\Unit::NANOSECOND);

?>

See also ext/hrtime manual.

1.2.1517.1. Specs

Short name

Extensions/Exthrtime

Rulesets

All, Appinfo, CE

Exakat since

1.1.5

PHP Version

All

Severity

Time To Fix

Precision

Very high

Available in

Entreprise Edition, Community Edition, Exakat Cloud