Req #79871 [NEW]: On Windows, php can sleep only in 1ms steps
From: michael dot vorisek at email dot cz
Operating system: Windows
PHP version: 7.4.8
Package: *General Issues
Bug Type: Feature/Change Request
Bug description:On Windows, php can sleep only in 1ms steps
Description:
------------
On Windows, php can sleep only in 1ms steps.
Not sure if it is related with gettimeofday function usage, as
microtime() seems to return "at least microseconds steps"
but "gettimeofday in reality returns only 1ms steps on Windows"
Test script:
---------------
$times = [];
$last = microtime(true);
for ($i = 0; $i < 10000; $i++) {
$t = microtime(true);
$times[] = ($t - $last) * 1000 * 1000;
$last = $t;
usleep(2);
// same issue... time_nanosleep(0, 2000);
}
print_r($times);
Expected result:
----------------
numbers lower than 1000 / 1 ms
Actual result:
--------------
Array
(
[0] => 0.95367431640625
[1] => 282.04917907715
[2] => 1029.9682617188
[3] => 964.87998962402
[4] => 999.21226501465
[5] => 991.8212890625
[6] => 1002.0732879639
[7] => 1002.0732879639
[8] => 996.82807922363
[9] => 994.20547485352
[10] => 998.97384643555
[11] => 998.97384643555
[12] => 993.96705627441
...
--
Edit bug report at https://bugs.php.net/bug.php?id=79871&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79871&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79871&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79871&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79871&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79871&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79871&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79871&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79871&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79871&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79871&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79871&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79871&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79871&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79871&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79871&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79871&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79871&r=mysqlcfg
Thread (1 message)
- michael dot vorisek at email dot cz