[php-src] Issue #12346: `usleep` takes more milisecons than expected on windows
| From: | parallels999 | Date: | Mon, 02 Oct 2023 17:37:44 +0000 |
| Subject: | [php-src] Issue #12346: `usleep` takes more milisecons than expected on windows | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-245477@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/12346
Author: parallels999
### Description
The following code:
```php
<?php
// Current time
echo (new DateTime('now'))->format('H:i:s.v'), "<br>";
// wait for 2 milliseconds
usleep(2000);
// back!
echo (new DateTime('now'))->format('H:i:s.v'), "<br>";
// wait for 100 microseconds
usleep(100);
// back again!
echo (new DateTime('now'))->format('H:i:s.v'), "<br>";
```
Resulted in this output:
```
18:18:42.576
18:18:42.592
18:18:42.623
```
But I expected this output instead:
```
18:18:42.576
18:18:42.578
18:18:42.578
```
This is just on windows, on linux works as expected, code from https://www.php.net/manual/en/function.usleep.php#examples
### PHP Version
8.2
### Operating System
Windows 10