Contents

measure(isolation:_:)

Measure the elapsed time to execute an asynchronous closure.

Declaration

func measure(isolation: isolated (any Actor)? = #isolation, _ work: () async throws -> Void) async rethrows -> Self.Instant.Duration

Discussion

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