Compare commits
3 Commits
ac87961e97
...
9eb016e8ec
| Author | SHA1 | Date |
|---|---|---|
|
|
9eb016e8ec | |
|
|
44491db7cc | |
|
|
310734d2f8 |
|
|
@ -11,12 +11,21 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
// swift-format-ignore-file
|
||||
// Note: Whitespace changes are used to workaround compiler bug
|
||||
// https://github.com/swiftlang/swift/issues/79285
|
||||
|
||||
@_exported import CoreMetrics
|
||||
import Foundation
|
||||
import Dispatch
|
||||
|
||||
@_exported import class CoreMetrics.Timer
|
||||
|
||||
#if canImport(FoundationEssentials)
|
||||
import FoundationEssentials
|
||||
#else
|
||||
import Foundation
|
||||
#endif
|
||||
|
||||
extension Timer {
|
||||
/// Convenience for measuring duration of a closure.
|
||||
///
|
||||
|
|
@ -123,8 +132,9 @@ extension Timer {
|
|||
@available(macOS 13, iOS 16, tvOS 16, watchOS 9, *)
|
||||
public func measure<Result, Failure: Error, Clock: _Concurrency.Clock>(
|
||||
clock: Clock = .continuous,
|
||||
body: () throws(Failure) -> Result
|
||||
) throws(Failure) -> Result where Clock.Duration == Duration {
|
||||
// DO NOT FIX THE WHITESPACE IN THE NEXT LINE UNTIL 5.10 IS UNSUPPORTED
|
||||
// https://github.com/swiftlang/swift/issues/79285
|
||||
body: () throws(Failure) -> Result) throws(Failure) -> Result where Clock.Duration == Duration {
|
||||
let start = clock.now
|
||||
defer {
|
||||
self.record(duration: start.duration(to: clock.now))
|
||||
|
|
@ -143,8 +153,9 @@ extension Timer {
|
|||
public func measure<Result, Failure: Error, Clock: _Concurrency.Clock>(
|
||||
clock: Clock = .continuous,
|
||||
isolation: isolated (any Actor)? = #isolation,
|
||||
body: () async throws(Failure) -> sending Result
|
||||
) async throws(Failure) -> sending Result where Clock.Duration == Duration {
|
||||
// DO NOT FIX THE WHITESPACE IN THE NEXT LINE UNTIL 5.10 IS UNSUPPORTED
|
||||
// https://github.com/swiftlang/swift/issues/79285
|
||||
body: () async throws(Failure) -> sending Result) async throws(Failure) -> sending Result where Clock.Duration == Duration {
|
||||
let start = clock.now
|
||||
defer {
|
||||
self.record(duration: start.duration(to: clock.now))
|
||||
|
|
|
|||
Loading…
Reference in New Issue