// continuous version
let continuousClock = ContinuousClock()
let continuousElapsed = try await continuousClock.measure {
try await Task.sleep(until: .now + .seconds(5), clock: .continuous)
}
print(continuousElapsed)
// suspending version
let suspendingClock = SuspendingClock()
let suspendingElapsed = try await suspendingClock.measure {
try await Task.sleep(until: .now + .seconds(5), clock: .suspending)
}
print(suspendingElapsed)
result:
0.000126 seconds
5.324980708 seconds
Swift version: Apple Swift version 5.7 (swiftlang-5.7.0.113.202 clang-1400.0.16.2)