Structs
struct BatchInputProvider
public struct BatchInputProvider<T> <: BenchInputProvider<T> {
public BatchInputProvider(let builder: () -> T)
}
Description: Specifies an input provider that generates the input for the entire benchmark batch in the buffer before execution.
Parent types:
init(() -> T)
public BatchInputProvider(let builder: () -> T)
Description: Specifies a default constructor.
Parameters:
- builder: () -> T: closure used to generate the benchmark input
mut func get(Int64)
public mut func get(idx: Int64): T
Description: Obtains elements. Its execution time is included in the benchmark measurement and then excluded from the result as part of the framework overhead.
Parameters:
- idx: Int64: element index
Returns:
- T: element value
mut func reset(Int64)
public mut func reset(max: Int64)
Description: Calls this function before the benchmark measurement. After this function is called, subsequent get(i) calls must successfully obtain the value of i in [0, max).
Parameters:
- max: Int64: maximum value
struct BatchSizeOneInputProvider
public struct BatchSizeOneInputProvider<T> <: BenchInputProvider<T>{
public BatchSizeOneInputProvider(let builder: () -> T)
}
Description: Specifies a benchmark input provider that generates input before each benchmark execution. It differs from GenerateEachInputProvider in that it allows measurement when the batch size is 1. Each benchmark test call is independent, so the input generation is never included in the measurement. This structure should be used if the quality of the result provided by GenerateEachInputProvider is poor. This may happen when the time required to generate the input is much longer than the actual benchmark, or if the execution time of the input generation is highly unstable.
Parent types:
init(() -> T)
public BatchSizeOneInputProvider(let builder: () -> T)
Description: Specifies a default constructor.
Parameters:
- builder: () -> T: lambda used to generate the benchmark test input
mut func get(Int64)
public mut func get(idx: Int64): T
Description: Obtains elements. Its execution time is included in the benchmark measurement and then excluded from the result as part of the framework overhead.
Parameters:
- idx: Int64: element index
Returns:
- T: element value
mut func reset(Int64)
public mut func reset(max: Int64)
Description: Calls this function before the benchmark measurement. After this function is called, subsequent get(i) calls must successfully obtain the value of i in [0, max).
Parameters:
- max: Int64: maximum value
struct CpuCycles
public struct CpuCycles <: Measurement {
public prop conversionTable: MeasurementUnitTable
public prop name: String
public prop textDescription: String
public func measure(): Float64
public func setup()
}
Description: Uses the local rdtscp instruction to measure the number of CPU cycles. It applies only to the x86 platform.
Parent types:
prop conversionTable
prop conversionTable: MeasurementUnitTable
Description: Provides the unit conversion table of the current time.
For example, [(1.0, "cycles")].
For details, see MeasurementUnitTable.
Type: MeasurementUnitTable
prop name
prop name: String
Description: Provides the only display name of the current time unit, for example, CpuCycles.
Type: String
func measure()
public func measure(): Float64
Description: Returns the number of CPU cycles executed.
Returns:
- Float64: data calculated, which is used for statistical analysis
func setup()
public func setup()
Description: Specifies the configuration action to be performed before measurement.
struct GenerateEachInputProvider
public struct GenerateEachInputProvider<T> <: BenchInputProvider<T>{
public GenerateEachInputProvider(let builder: () -> T)
}
Description: Benchmark input provider that generates input before each benchmark execution. The generation time is included in the benchmark measurement and then excluded from the final result as part of the framework overhead.
Parent types:
init(() -> T)
public GenerateEachInputProvider(let builder: () -> T)
Description: Specifies a default constructor.
Parameters:
- builder: () -> T: closure used to generate the benchmark input
mut func get(Int64)
public mut func get(idx: Int64): T
Description: Obtains elements. Its execution time is included in the benchmark measurement and then excluded from the result as part of the framework overhead.
Parameters:
- idx: Int64: element index
Returns:
- T: element value
mut func reset(Int64)
public mut func reset(max: Int64)
Description: Calls this function before the benchmark measurement. After this function is called, subsequent get(i) calls must successfully obtain the value of i in [0, max).
Parameters:
- max: Int64: maximum value
struct ImmutableInputProvider
public struct ImmutableInputProvider<T> <: BenchInputProvider<T> {
public ImmutableInputProvider(let data: T)
}
Description: Specifies the simplest input provider that simply copies data for each invocation of the benchmark. It is applicable to the scenario where the benchmark test does not change the input. This is the default provider used within the framework.
Parent types:
init(T)
public ImmutableInputProvider(let data: T)
Description: Specifies a default constructor.
Parameters:
- data: T: input of the benchmark test
mut func get(Int64)
public mut func get(idx: Int64): T
Description: Obtains elements. Its execution time is included in the benchmark measurement and then excluded from the result as part of the framework overhead.
Parameters:
- idx: Int64: element index
Returns:
- T: element value
static func createOrExisting(T, Int64)
public static func createOrExisting(arg: T, x!:Int64=0): ImmutableInputProvider<T>
Description: Creates or obtains an ImmutableInputProvider object.
Parameters:
- arg: T: parameter to be copied by the provider
- x!: Int64: parameter added for overloading
Returns:
- ImmutableInputProvider<T>: input provider
static func createOrExisting<U>(U): U where U <: BenchInputProvider<T>
public static func createOrExisting<U>(arg: U): U where U <: BenchInputProvider<T>
Description: Creates or obtains a BenchInputProvider subtype object.
Parameters:
- arg: T: parameter to be copied by the provider
Returns:
- U where U <: BenchInputProvider<T>: input provider
struct Perf
public struct Perf <: Measurement {
public prop conversionTable: MeasurementUnitTable
public prop name: String
public prop textDescription: String
public init()
public init(counter: PerfCounter)
public func measure(): Float64
public func setup()
}
Description: Uses the Linux system call perf_event_open to measure various hardware and software CPU counters. It is available only on Linux.
Parent types:
prop conversionTable
prop conversionTable: MeasurementUnitTable
Description: Provides the conversion table of the corresponding CPU counter.
Type: MeasurementUnitTable
prop name
prop name: String
Description: Provides the only display name for the current CPU counter, for example, Perf(cycles).
Type: String
init()
public init()
Description: Uses the default constructor of the CPU cycle counter.
init(PerfCounter)
public init(counter: PerfCounter)
Description: Specifies the constructor of the CPU counter to be measured.
Parameters:
- counter: PerfCounter
func measure()
public func measure(): Float64
Description: Returns the value of a specified CPU counter.
Returns:
- Float64: data calculated, which is used for statistical analysis
func setup()
func setup()
Description: Specifies the initialization routine of the CPU counter. This function is called before each benchmark step.
struct TimeNow
public struct TimeNow <: Measurement {
public prop conversionTable: MeasurementUnitTable
public prop name: String
public prop textDescription: String
public init()
public init(unit: ?TimeUnit)
}
Description: Implements measurement, which is used to measure the time taken to execute a function.
Parent types:
prop conversionTable
prop conversionTable: MeasurementUnitTable
Description: Provides the unit conversion table of the current time.
For example, [(1.0, "ns"), (1e3, "us"), (1e6, "ms"), (1e9, "s")].
For details, see MeasurementUnitTable.
Type: MeasurementUnitTable
prop name
prop name: String
Description: Provides the only display name of the current time unit, for example, Duration(ns) or Duration(s).
Type: String
prop textDescription
prop textDescription: String
Description: Specifies a simple text describing a measurement that will be displayed in some reports.
Type: String
init()
public init()
Description: Automatically selects the default constructor for the output format.
init(?TimeUnit)
public init(unit: ?TimeUnit)
Description: Specifies the time unit to be used when the result is printed.
Parameters:
- unit: ?TimeUnit : specified time unit
func measure()
public func measure(): Float64
Description: Obtains the current time for statistical analysis.
Returns:
- Float64: data calculated, which is used for statistical analysis