Structure

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 Type:

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 Type:

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 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 Type:

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 Type:

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 TimeNow

public struct TimeNow <: Measurement {
    public init()
    public init(unit: ?TimeUnit)
}

Description: Implementation of Measurement, used to measure the time taken to execute a function.

Parent Type:

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:

func measure(() -> Unit)

public func measure(f: () -> Unit): Float64

Description: Measures the execution duration of f for statistical analysis.

Parameters:

  • f: () -> Unit: executor whose execution time is calculated

Returns:

  • Float64: calculated data, which is used for statistical analysis

func measureIntermediate()

public func measureIntermediate(): Float64

Description: Obtains the current time for statistical analysis.

Returns:

  • Float64: calculated data, which is used for statistical analysis

func toString(Float64)

public func toString(duration: Float64): String

Description: Prints the provided time value according to the time unit.

Parameters:

  • duration: Float64: time to be printed

Returns:

  • String: time value formatted as a string in the specified unit