xref: /PHP-8.4/ext/standard/tests/hrtime/hrtime.phpt (revision 849fdcae)
1--TEST--
2Test hrtime() aligns with microtime()
3--FLAKY--
4This test frequently fails in CI
5--FILE--
6<?php
7
8$m0 = microtime(true);
9$h0 = hrtime(true);
10for ($i = 0; $i < 1024*1024; $i++);
11$h1 = hrtime(true);
12$m1 = microtime(true);
13
14$d0 = ($m1 - $m0)*1000000000.0;
15$d1 = $h1 - $h0;
16
17/* Relative uncertainty. */
18$d = abs($d0 - $d1)/$d1;
19
20if ($d > 0.05) {
21    print "FAIL, $d";
22} else {
23    print "OK, $d";
24}
25
26?>
27--EXPECTF--
28OK, %f
29