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