Initializerpackage-benchmark 1.27.1Benchmark
init(_:configuration:closure:setup:teardown:)
Definition of an async throwing Benchmark
Benchmark+ConvenienceInitializers.swift:87@discardableResult convenience init?<SetupResult>(_ name: String, configuration: Benchmark.Configuration = Benchmark.defaultConfiguration, closure: @escaping (_ benchmark: Benchmark, SetupResult) async throws -> Void, setup: @escaping (() async throws -> SetupResult), teardown: BenchmarkTeardownHook? = nil)
Parameters
- name
The name used for display purposes of the benchmark (also used for matching when comparing to baselines)
- configuration
Defines the settings that should be used for this benchmark
- closure
The actual async throwing benchmark closure that will be measured, this one takes one additional parameter apart from the benchmark instance, which is the generic SetupResult type returned from the setup
See also
init?(String, configuration: Benchmark.Configuration, closure: @escaping BenchmarkThrowingClosure, setup: BenchmarkSetupHook?, teardown: BenchmarkTeardownHook?
) Definition of a throwing Benchmark
init?<SetupResult>(String, configuration: Benchmark.Configuration, closure: @escaping (_ benchmark: Benchmark, SetupResult) throws -> Void, setup: @escaping (() async throws -> SetupResult), teardown: BenchmarkTeardownHook?
) Definition of a throwing Benchmark
init?<SetupResult>(String, configuration: Benchmark.Configuration, closure: @escaping (_ benchmark: Benchmark, SetupResult) -> Void, setup: @escaping (() async throws -> SetupResult), teardown: BenchmarkTeardownHook?
) Definition of a Benchmark
init?(String, configuration: Benchmark.Configuration, closure: @escaping BenchmarkClosure, setup: BenchmarkSetupHook?, teardown: BenchmarkTeardownHook?
) Definition of a Benchmark
init?(String, configuration: Benchmark.Configuration, closure: @escaping BenchmarkAsyncThrowingClosure, setup: BenchmarkSetupHook?, teardown: BenchmarkTeardownHook?
) Definition of an async throwing Benchmark
init?(String, configuration: Benchmark.Configuration, closure: @escaping BenchmarkAsyncClosure, setup: BenchmarkSetupHook?, teardown: BenchmarkTeardownHook?
) Definition of a Benchmark
init?<SetupResult>(String, configuration: Benchmark.Configuration, closure: @escaping (_ benchmark: Benchmark, SetupResult) async -> Void, setup: @escaping (() async throws -> SetupResult), teardown: BenchmarkTeardownHook?
) Definition of an async Benchmark
Other members in extension
Types
struct Configuration
The configuration settings for running a benchmark.
Typealiases
typealias BenchmarkAsyncClosure
typealias BenchmarkAsyncThrowingClosure
typealias BenchmarkClosure
typealias BenchmarkCustomMetricMeasurement
typealias BenchmarkMeasurementSynchronization
typealias BenchmarkSetupHook
Alias for closures used to hook into setup / teardown
typealias BenchmarkTeardownHook
typealias BenchmarkThrowingClosure
Type members
init(from: any Decoder
) throws static var benchmarks: [Benchmark]
static var defaultConfiguration: Configuration
Hook for setting defaults for a whole benchmark suite
static var setup: BenchmarkSetupHook?
This closure if set, will be run before a targets benchmarks are run, but after they are registered
static var shutdownHook: BenchmarkTeardownHook?
static var startupHook: BenchmarkSetupHook?
static var teardown: BenchmarkTeardownHook?
This closure if set, will be run after a targets benchmarks run, but after they are registered
static func blackHole(some Any
) A function to foil compiler optimizations that would otherwise optimize out code you want to benchmark.
static func == (lhs: Benchmark, rhs: Benchmark
) -> Bool
Show obsolete interfaces (1)
Hide obsolete interfaces
static var checkAbsoluteThresholds: Bool
Set to true if this benchmark results should be compared with an absolute threshold when
--check-absolute
is specified on the command line. An implementation can then choose to configure thresholds differently for such comparisons by e.g. reading them in from external storage.
Instance members
var baseName: String
The name of the benchmark without any of the tags appended
var configuration: Configuration
The configuration to use for this benchmark
var currentIteration: Int
The current benchmark iteration (also includes warmup iterations), can be useful when e.g. unique keys will be needed for different iterations
var customMetricMeasurement: BenchmarkCustomMetricMeasurement?
var executablePath: String?
var failureReason: String?
The reason for a benchmark failure, not set if successful
var measurementPostSynchronization: BenchmarkMeasurementSynchronization?
var measurementPreSynchronization: BenchmarkMeasurementSynchronization?
var name: String
The name used for display purposes of the benchmark (also used for matching when comparing to baselines)
var scaledIterations: Range<Int>
Convenience range to iterate over for benchmarks
var setupState: Any?
The state returned from setup, if any - need to be cast as required
var target: String
Some internal state for display purposes of the benchmark by the BenchmarkTool
func error(String
) Used to signify that a given benchmark have failed for some reason
func hash(into: inout Hasher
) func measurement(BenchmarkMetric, Int
) measurement
registers custom metric measurementsfunc run(
) func startMeasurement(
) If the benchmark contains a preamble setup that should not be part of the measurement
startMeasurement
can be called explicitly to define when measurement should begin. Otherwise the whole benchmark will be measured.func stopMeasurement(
) If the benchmark contains a postample that should not be part of the measurement
stopMeasurement
can be called explicitly to define when measurement should stop. Otherwise the whole benchmark will be measured.