mirror of
https://github.com/php/php-src.git
synced 2025-08-21 01:45:16 +02:00
Merge branch 'PHP-7.4'
This commit is contained in:
commit
98d05389a7
1 changed files with 16 additions and 7 deletions
|
@ -11,10 +11,11 @@ Michele Orselli mo@ideato.it
|
||||||
#PHPTestFest Cesena Italia on 2009-06-20
|
#PHPTestFest Cesena Italia on 2009-06-20
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
$time = microtime(true) + 2;
|
$time = microtime(true) + 2;
|
||||||
var_dump(time_sleep_until( (int)$time ));
|
$sleepUntil = (int) $time;
|
||||||
$now = microtime(true);
|
var_dump(time_sleep_until($sleepUntil));
|
||||||
if(substr(PHP_OS, 0, 3) == 'WIN' ) {
|
$now = microtime(true);
|
||||||
|
if (substr(PHP_OS, 0, 3) == 'WIN') {
|
||||||
// on windows, time_sleep_until has millisecond accuracy while microtime() is accurate
|
// on windows, time_sleep_until has millisecond accuracy while microtime() is accurate
|
||||||
// to 10th of a second. this means there can be up to a .9 millisecond difference
|
// to 10th of a second. this means there can be up to a .9 millisecond difference
|
||||||
// which will fail this test. this test randomly fails on Windows and this is the cause.
|
// which will fail this test. this test randomly fails on Windows and this is the cause.
|
||||||
|
@ -26,9 +27,17 @@ Michele Orselli mo@ideato.it
|
||||||
// In practice, on slower machines even that can fail, so giving yet 50ms or more.
|
// In practice, on slower machines even that can fail, so giving yet 50ms or more.
|
||||||
$tmp = round($now, 3);
|
$tmp = round($now, 3);
|
||||||
$now = $tmp >= (int)$time ? $tmp : $tmp + .05;
|
$now = $tmp >= (int)$time ? $tmp : $tmp + .05;
|
||||||
}
|
}
|
||||||
var_dump($now >= (int)$time);
|
|
||||||
|
if ($now >= $sleepUntil) {
|
||||||
|
echo "Success\n";
|
||||||
|
} else {
|
||||||
|
echo "Sleep until (before truncation): ", $time, "\n";
|
||||||
|
echo "Sleep until: ", $sleepUntil, "\n";
|
||||||
|
echo "Now: ", $now, "\n";
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
bool(true)
|
bool(true)
|
||||||
bool(true)
|
Success
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue