Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AndriusA
Copy link

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
Copy link
Author

note: need to remove Timer.record(duration: Duration) when #133 lands

@FranzBusch
Copy link
Member

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

FranzBusch added a commit that referenced this pull request Apr 22, 2024
# Motivation

This PR supersedes #135. The goal is to make it easier to measure asynchronous code when using `Metrics`.

# Modification

This PR does:
- Deprecate the current static method for measuring synchronous code
- Add a new instance method to measure synchronous code
- Add a new instance method to measure asynchronous code

# Result

It is now easier to measure asynchronous code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants