summaryrefslogtreecommitdiff
path: root/ext/standard/tests/hrtime/hrtime.phpt
blob: bac127bf44e13e73f50bec4b91f84e74e515aac0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
--TEST--
Test hrtime() aligns with microtime()
--FILE--
<?php

$m0 = microtime(true);
$h0 = hrtime(true);
for ($i = 0; $i < 1024*1024; $i++);
$h1 = hrtime(true);
$m1 = microtime(true);

$d0 = ($m1 - $m0)*1000000000.0;
$d1 = $h1 - $h0;

/* Relative uncertainty. */
$d = abs($d0 - $d1)/$d1;

if ($d > 0.05) {
	print "FAIL, $d";
} else {
	print "OK, $d";
}

?>
--EXPECTF--
OK, %f