Structurepackage-benchmark 1.27.2Benchmark
BenchmarkClock
BenchmarkClock.swift:28struct BenchmarkClock
Citizens in Benchmark
Conformances
protocol Clock<Duration>
A mechanism in which to measure time, and delay work until a given point in time.
protocol Copyable
A type whose values can be implicitly or explicitly copied.
protocol Escapable
protocol Sendable
Types
struct Instant
A continuous point in time used for
BenchmarkClock
.
Type members
init(
) static var now: BenchmarkClock.Instant
The current continuous instant.
Instance members
var minimumResolution: Swift.Duration
The minimum non-zero resolution between any two calls to
now
.var now: BenchmarkClock.Instant
The current continuous instant.
func sleep(until: Instant, tolerance: Swift.Duration?
) async throws Suspend task execution until a given deadline within a tolerance. If no tolerance is specified then the system may adjust the deadline to coalesce CPU wake-ups to more efficiently process the wake-ups in a more power efficient manner.
Type features
static var internalUTC: BenchmarkClock
A clock that measures time that always increments but does not stop incrementing while the system is asleep.
Instance features
func measure(() throws -> Void
) rethrows -> Self.Instant.Duration Measure the elapsed time to execute a closure.
func measure(isolation: isolated (any Actor)?, () async throws -> Void
) async rethrows -> Self.Instant.Duration Measure the elapsed time to execute an asynchronous closure.
func sleep(for: Self.Instant.Duration, tolerance: Self.Instant.Duration?
) async throws Suspends for the given duration.