-
Notifications
You must be signed in to change notification settings - Fork 70
Add Timer.measure
methods
#140
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
Conversation
@swift-server-bot test this please |
@swift-server-bot add to allowlist |
There was a problem hiding this 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.
Sources/Metrics/Metrics.swift
Outdated
return try body() | ||
} | ||
|
||
/// Convenience for measuring duration of a closure with a provided clock. |
There was a problem hiding this comment.
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?
/// Convenience for measuring duration of a closure with a provided clock. | |
/// Convenience for measuring duration of a closure. |
@swift-server-bot test this please |
8cc9d38
to
199b458
Compare
@fabianfett @simonjbeaumont @czechboy0 I dusted off this PR again and brought up to the latest Swift standards. If you could take another look that would be great. |
@czechboy0 To address your feedback I removed the deprecation. This will allow current adopters or adopter with platform requirements to stay with the existing API. |
199b458
to
fca8582
Compare
Thanks, Franz. And the second question - are we okay only offering this new method to packages with the raised OS requirements? |
Yes, I think that's fine. The other method exists and the intention of the new one is to take advantage of Clock. |
# 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.
fca8582
to
c91aab6
Compare
Right, it's not a big inconvenience - it might just be confusing that the instance method requires a newer OS (because it uses Clock), but the static method doesn't. We could add a |
I get your point but I really don't think we should add those. Clock is the way forward and there is the existing static method that provides an escape hatch. We can always add it is somebody asks for it. |
Motivation
This PR supersedes #135. The goal is to make it easier to measure asynchronous code when using
Metrics
.Modification
This PR does: