-
Notifications
You must be signed in to change notification settings - Fork 68
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
base: main
Are you sure you want to change the base?
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 |
b541236
to
8cc9d38
Compare
# 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.
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. |
@@ -24,6 +24,9 @@ extension Timer { | |||
/// - label: The label for the Timer. | |||
/// - dimensions: The dimensions for the Timer. | |||
/// - body: Closure to run & record. | |||
#if compiler(>=6.0) |
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.
Do we think it's okay to have a deprecation based on a compiler version? What's the experience for an adopter who supports the same 3 Swift versions as us, do they also have to provide two solutions?
Also, the new API has an OS requirement, so we should make sure we don't put any adopters into a situation where they can't fix this warning without bumping their OS requirement (which today requires a major bump).
/// - clock: The clock used for measuring the duration. Defaults to the continuous clock. | ||
/// - body: The closure to record the duration of. | ||
@inlinable | ||
@available(macOS 13, iOS 16, tvOS 16, watchOS 9, *) |
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.
What's the recommendation for adopters who aren't yet on these OS versions as deployment targets?
Should we consider offering a variant if this method without the bumped OS requirements, which use pre-Clock way to measure time, for packages with older OS deployment targets? Or do we just recommend they write their own?
Motivation
This PR supersedes #135. The goal is to make it easier to measure asynchronous code when using
Metrics
.Modification
This PR does: