Contents

measure(_:)

Measure the elapsed time to execute an asynchronous closure.

Declaration

nonisolated(nonsending) func measure(_ work: nonisolated(nonsending) () async throws -> Void) async rethrows -> Self.Instant.Duration

Discussion

  let clock = ContinuousClock()
  let elapsed = await clock.measure {
     await someWork()
  }