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

Add Timer.measure methods #140

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Add Timer.measure methods #140

wants to merge 2 commits into from

Conversation

FranzBusch
Copy link
Contributor

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

# 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.
@FranzBusch
Copy link
Contributor Author

@swift-server-bot test this please

@Lukasa
Copy link
Contributor

Lukasa commented Apr 22, 2024

@swift-server-bot add to allowlist

Copy link
Contributor

@gjcairo gjcairo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a nit about docs.

return try body()
}

/// Convenience for measuring duration of a closure with a provided clock.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the doc for this method and the non-async version don't match. Maybe remove the last bit to match that one, since we're defaulting the clock param anyways?

Suggested change
/// Convenience for measuring duration of a closure with a provided clock.
/// Convenience for measuring duration of a closure.

@FranzBusch
Copy link
Contributor Author

@swift-server-bot test this please

@FranzBusch FranzBusch enabled auto-merge (squash) May 9, 2024 09:57
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

4 participants