swift-metrics icon indicating copy to clipboard operation
swift-metrics copied to clipboard

adds support for swift-concurrency Duration and async closures for Timer measurements

Open AndriusA opened this issue 2 years ago • 2 comments

extends Timer with support for standard lib Duration type and measurements to relative to Instant on Clocks using Duration

Motivation:

Use of Timer is currently clunky with async code as any durations need to be manually converted to microseconds (et al)

Modifications:

Extends Timer with:

  • method to record duration since Clock.Instant on any Clock using Duration
  • methods that use static continuous/suspending clock by default with corresponding instant types
  • methods to measure duration of an async closure with provided Clock or default ContinuousClock

Result:

Additional Timer methods available for measuring async work

AndriusA avatar Jun 23 '23 10:06 AndriusA

note: need to remove Timer.record(duration: Duration) when https://github.com/apple/swift-metrics/pull/133 lands

AndriusA avatar Jun 23 '23 10:06 AndriusA

@AndriusA Can you update this PR so we can start to review it?

FranzBusch avatar Aug 10 '23 12:08 FranzBusch