xref: /PHP-8.0/ext/standard/tests/time/001.phpt (revision c5401854)
1--TEST--
2microtime() function
3--SKIPIF--
4<?php
5    if (!function_exists('microtime'))  die('skip microtime() not available');
6?>
7--FILE--
8<?php
9$passed = 0;
10$failed = 0;
11$last_m = 0;
12$last_t = 0;
13$result = '';
14
15set_time_limit(0);
16
17for ($i=1;$i<=100000;$i++) {
18    list($micro,$time)=explode(" ",microtime());
19    if ($time > $last_t || ($time == $last_t && $micro >= $last_m)) {
20        $passed++;
21    } else if ($failed++ <=10) {
22        $result .= sprintf('%06d', $i).": $time $micro < $last_t $last_m\n";
23    }
24    $last_m = $micro;
25    $last_t = $time;
26}
27echo "Passed: $passed\n";
28echo "Failed: $failed\n";
29echo $result;
30?>
31--EXPECT--
32Passed: 100000
33Failed: 0
34