-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed as duplicate of#72095
Closed as duplicate of#72095
Copy link
Labels
ConcurrencуArea → standard library: The `Concurrency` module under the standard library umbrellaArea → standard library: The `Concurrency` module under the standard library umbrellaWindowsPlatform: WindowsPlatform: WindowsbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.standard libraryArea: Standard library umbrellaArea: Standard library umbrellaswift 6.0timeArea → standard library → Concurrency: Time APIsArea → standard library → Concurrency: Time APIsunexpected behaviorBug: Unexpected behavior or incorrect outputBug: Unexpected behavior or incorrect output
Description
Description
Task.sleep appears to be significantly slower than expected on Windows.
Reproduction
import Foundation
let clock = ContinuousClock()
let duration = try await clock.measure {
for _ in 0..<100 {
try await Task.sleep(for: .microseconds(1000))
}
}
print(duration)
prints 26.889839124999998 seconds on Windows
Expected behavior
Linux: prints 0.128345333 seconds
$ swiftc --version
Swift version 5.10.1 (swift-5.10.1-RELEASE)
Target: aarch64-unknown-linux-gnu
$ cat /etc/debian_version
12.6
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 12 (bookworm)
Release: 12
Codename: bookworm
macOS: prints 0.201219667 seconds
--
I'd expect Windows to perform comparably, rather than be off by roughly 100x-200x.
Environment
swiftc --version
Swift version 6.0-dev (LLVM 31f0cdc6d5ff8a6, Swift aa0786c)
Target: x86_64-unknown-windows-msvc
Microsoft Windows [Version 10.0.22631.4037]
Parallels ARM virtual machine
Additional information
Removing the for loop and changing the duration to 100,000 microseconds results in printing almost exactly 0.1 seconds on macOS and Linux (as expected), but 0.385826416 seconds on Windows (almost 4x as long).
Metadata
Metadata
Assignees
Labels
ConcurrencуArea → standard library: The `Concurrency` module under the standard library umbrellaArea → standard library: The `Concurrency` module under the standard library umbrellaWindowsPlatform: WindowsPlatform: WindowsbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.standard libraryArea: Standard library umbrellaArea: Standard library umbrellaswift 6.0timeArea → standard library → Concurrency: Time APIsArea → standard library → Concurrency: Time APIsunexpected behaviorBug: Unexpected behavior or incorrect outputBug: Unexpected behavior or incorrect output