Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

结构体

struct BatchInputProvider<T>

public struct BatchInputProvider<T> <: BenchInputProvider<T> {
    public BatchInputProvider(let builder: () -> T)
}

功能:输入提供程序,在执行之前在缓冲区中生成整个基准批次的输入。

父类型:

BatchInputProvider(() -> T)

public BatchInputProvider(let builder: () -> T)

功能:BatchInputProvider构造函数。

参数:

  • builder: () -> T - 用于生成基准测试输入的闭包。

func get(Int64)

public mut func get(idx: Int64): T

功能:获取元素,该函数的执行时间包含在基准测量中,然后作为框架开销计算的一部分从结果中排除。

参数:

  • idx: Int64 - 元素索引值。

返回值:

  • T - 元素值。

func reset(Int64)

public mut func reset(max: Int64)

功能:在基准测量之前调用。调用此函数后,后续的 get(i) 调用必须成功获取 [0, max) 中的 i

参数:

  • max: Int64 - 最大值。

struct BatchSizeOneInputProvider<T>

public struct BatchSizeOneInputProvider<T> <: BenchInputProvider<T>{
    public BatchSizeOneInputProvider(let builder: () -> T)
}

功能:基准输入提供程序,在每次执行基准之前生成输入。 与 GenerateEachInputProvider 的区别在于,当批量大小为 1 时,我们可以测量。 每个基准测试调用都是独立的,因此输入生成永远不会包含在测量中。 如果 GenerateEachInputProvider 给出的结果质量较差,则应使用。 这种情况可能会发生,因为生成输入所需的时间比实际基准要多得多,或者如果输入生成的执行时间非常不稳定。

父类型:

BatchSizeOneInputProvider(() -> T)

public BatchSizeOneInputProvider(let builder: () -> T)

功能:BatchSizeOneInputProvider构造函数。

参数:

  • builder: () -> T - 用于生成基准测试输入的 lambda 。

func get(Int64)

public mut func get(idx: Int64): T

功能:获取元素,该函数的执行时间包含在基准测量中,然后作为框架开销计算的一部分从结果中排除。

参数:

  • idx: Int64 - 元素索引值。

返回值:

  • T - 元素值。

func reset(Int64)

public mut func reset(max: Int64)

功能:在基准测量之前调用。调用此函数后,后续的 get(i) 调用必须成功获取 [0, max) 中的 i

参数:

  • max: Int64 - 最大值。

struct CpuCycles

public struct CpuCycles <: Measurement {}

功能:使用本机 rdtscp 指令测量 CPU 周期数。仅适用于 x86 平台。

父类型:

prop conversionTable

prop conversionTable: MeasurementUnitTable

功能:提供当前时间的单位换算表。 例如 [(1.0, "cycles")]

类型:MeasurementUnitTable

prop name

prop name: String

功能:提供当前时间单位唯一的显示名称,例如:CpuCycles

类型:String

prop textDescription

prop textDescription: String

功能:描述此测量的简单文本将显示在某些报告中。

类型:String

func measure()

public func measure(): Float64

功能:返回执行了多少个 CPU 周期。

返回值:

  • Float64 - 计算得到的数据,用于统计分析。

func setup()

public func setup()

功能:在测量前执行的配置动作。

struct GenerateEachInputProvider<T>

public struct GenerateEachInputProvider<T> <: BenchInputProvider<T>{
    public GenerateEachInputProvider(let builder: () -> T)
}

功能:基准输入提供程序,在每次执行基准之前生成输入。 生成时间包含在基准测量中,然后作为框架开销计算的一部分从最终结果中排除。

父类型:

GenerateEachInputProvider(() -> T)

public GenerateEachInputProvider(let builder: () -> T)

功能:GenerateEachInputProvider构造函数。

参数:

  • builder: () -> T - 用于生成基准测试输入的闭包。

func get(Int64)

public mut func get(idx: Int64): T

功能:获取元素,该函数的执行时间包含在基准测量中,然后作为框架开销计算的一部分从结果中排除。

参数:

  • idx: Int64 - 元素索引值。

返回值:

  • T - 元素值。

func reset(Int64)

public mut func reset(max: Int64)

功能:在基准测量之前调用。调用此函数后,后续的 get(i) 调用必须成功获取 [0, max) 中的 i

参数:

  • max: Int64 - 最大值。

struct ImmutableInputProvider<T>

public struct ImmutableInputProvider<T> <: BenchInputProvider<T> {
    public ImmutableInputProvider(let data: T)
}

功能:最简单的输入提供程序,只需为基准测试的每次调用复制数据。适用于基准测试不会改变输入的情况。它在框架内默认使用。

父类型:

ImmutableInputProvider(T)

public ImmutableInputProvider(let data: T)

功能:ImmutableInputProvider构造函数。

参数:

  • data: T - 基准测试的输入。

func get(Int64)

public mut func get(idx: Int64): T

功能:获取元素,该函数的执行时间包含在基准测量中,然后作为框架开销计算的一部分从结果中排除。

参数:

  • idx: Int64 - 元素索引值。

返回值:

  • T - 元素值。

static func createOrExisting(T, Int64)

public static func createOrExisting(arg: T, x!:Int64=0): ImmutableInputProvider<T>

功能:创建或获取一个 ImmutableInputProvider 对象。

参数:

  • arg: T - 提供器需复制的参数。
  • x!: Int64 - 为实现重载而增加的参数。

返回值:

  • ImmutableInputProvider<T> - 输入提供器。

static func createOrExisting<U>(U)

public static func createOrExisting<U>(arg: U): U where U <: BenchInputProvider<T>

功能:创建或获取一个 BenchInputProvider 的子类型对象。

参数:

  • arg: T - 提供器需复制的参数。

返回值:

  • U - 输入提供器。

struct KeyBaseline

public struct KeyBaseline <: KeyFor<String> {}

功能:用于在 Configuration 中作为对应配置项的键值

例如:

let conf = Configuration()
conf.set(KeyBaseline.baseline, "baseline")

父类型:

prop baseline

public static prop baseline: Baseline

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyBaselinePath

public struct KeyBaselinePath <: KeyFor<String> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop baselinePath

public static prop baselinePath: BaselinePath

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyBatchSize

public struct KeyBatchSize <: KeyFor<Int64> & KeyFor<Range<Int64>> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop batchSize

public static prop batchSize: BatchSize

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyBench

public struct KeyBench <: KeyFor<Bool> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop bench

public static prop bench: Bench

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyCaptureOutput

public struct KeyCaptureOutput <: KeyFor<Bool> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop captureOutput

public static prop captureOutput: CaptureOutput

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyCoverageGuided

public struct KeyCoverageGuided <: KeyFor<Bool> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop coverageGuided

public static prop coverageGuided: CoverageGuided

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyCoverageGuidedBaselineScore

public struct KeyCoverageGuidedBaselineScore <: KeyFor<Int64> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop coverageGuidedBaselineScore

public static prop coverageGuidedBaselineScore: CoverageGuidedBaselineScore

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyCoverageGuidedInitialSeeds

public struct KeyCoverageGuidedInitialSeeds <: KeyFor<Int64> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop coverageGuidedInitialSeeds

public static prop coverageGuidedInitialSeeds: CoverageGuidedInitialSeeds

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyCoverageGuidedMaxCandidates

public struct KeyCoverageGuidedMaxCandidates <: KeyFor<Int64> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop coverageGuidedMaxCandidates

public static prop coverageGuidedMaxCandidates: CoverageGuidedMaxCandidates

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyCoverageGuidedNewCoverageBonus

public struct KeyCoverageGuidedNewCoverageBonus <: KeyFor<Int64> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop coverageGuidedNewCoverageBonus

public static prop coverageGuidedNewCoverageBonus: CoverageGuidedNewCoverageBonus

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyCoverageGuidedNewCoverageScore

public struct KeyCoverageGuidedNewCoverageScore <: KeyFor<Int64> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop coverageGuidedNewCoverageScore

public static prop coverageGuidedNewCoverageScore: CoverageGuidedNewCoverageScore

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyDeathAware

public struct KeyDeathAware <: KeyFor<Bool> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop deathAware

public static prop deathAware: DeathAware

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyDryRun

public struct KeyDryRun <: KeyFor<Bool> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop dryRun

public static prop dryRun: DryRun

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyExcludeTags

public struct KeyExcludeTags <: KeyFor<String> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop excludeTags

public static prop excludeTags: ExcludeTags

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyExplicitGC

public struct KeyExplicitGC <: KeyFor<ExplicitGcType> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop explicitGC

public static prop explicitGC: ExplicitGC

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyFilter

public struct KeyFilter <: KeyFor<String> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop filter

public static prop filter: Filter

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyFromTopLevel

public struct KeyFromTopLevel <: KeyFor<Bool> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop fromTopLevel

public static prop fromTopLevel: FromTopLevel

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyGenerationSteps

public struct KeyGenerationSteps <: KeyFor<Int64> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop generationSteps

public static prop generationSteps: GenerationSteps

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyHelp

public struct KeyHelp <: KeyFor<Bool> {}

功能:用于在配置信息中指定是否打印帮助信息。

父类型:

prop help

public static prop help: KeyHelp

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyIncludeTags

public struct KeyIncludeTags <: KeyFor<String> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop includeTags

public static prop includeTags: IncludeTags

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyInternalTestrunnerInputPath

public struct KeyInternalTestrunnerInputPath <: KeyFor<String> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop internalTestrunnerInputPath

public static prop internalTestrunnerInputPath: InternalTestrunnerInputPath

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyMeasurement

public struct KeyMeasurement <: KeyFor<Measurement> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop measurement

public static prop measurement: Measurement

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyMeasurementInfo

public struct KeyMeasurementInfo <: KeyFor<MeasurementInfo> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop measurementInfo

public static prop measurementInfo: MeasurementInfo

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyMinBatches

public struct KeyMinBatches <: KeyFor<Int64> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop minBatches

public static prop minBatches: MinBatches

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyMinDuration

public struct KeyMinDuration <: KeyFor<Duration> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop minDuration

public static prop minDuration: MinDuration

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyNoCaptureOutput

public struct KeyNoCaptureOutput <: KeyFor<Bool> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop noCaptureOutput

public static prop noCaptureOutput: NoCaptureOutput

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyNoColor

public struct KeyNoColor <: KeyFor<Bool> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop noColor

public static prop noColor: NoColor

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyOptimizeMocksForBench

public struct KeyOptimizeMocksForBench <: KeyFor<Bool> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop optimizeMocksForBench

public static prop optimizeMocksForBench: OptimizeMocksForBench

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyParallel

public struct KeyParallel <: KeyFor<Bool> & KeyFor<String> & KeyFor<Int64> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop parallel

public static prop parallel: Parallel

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyRandomSeed

public struct KeyRandomSeed <: KeyFor<Int64> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop randomSeed

public static prop randomSeed: RandomSeed

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyReductionSteps

public struct KeyReductionSteps <: KeyFor<Int64> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop reductionSteps

public static prop reductionSteps: ReductionSteps

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyReportFormat

public struct KeyReportFormat <: KeyFor<String> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop reportFormat

public static prop reportFormat: ReportFormat

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyReportPath

public struct KeyReportPath <: KeyFor<String> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop reportPath

public static prop reportPath: ReportPath

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyShowAllOutput

public struct KeyShowAllOutput <: KeyFor<Bool> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop showAllOutput

public static prop showAllOutput: ShowAllOutput

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyShowTags

public struct KeyShowTags <: KeyFor<Bool> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop showTags

public static prop showTags: ShowTags

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeySkip

public struct KeySkip <: KeyFor<Bool> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop skip

public static prop skip: Skip

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyTimeout

public struct KeyTimeout <: KeyFor<Duration> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop timeout

public static prop timeout: Timeout

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyTimeoutEach

public struct KeyTimeoutEach <: KeyFor<String> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop timeoutEach

public static prop timeoutEach: TimeoutEach

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyTimeoutHandler

public struct KeyTimeoutHandler <: KeyFor<(TestCaseInfo) -> Unit> {}

功能:支持在配置信息中指定超时处理的句柄。

例如:

let conf = Configuration()
conf.set(KeyTimeoutHandler.timeoutHandler, { info => /*...*/ })

父类型:

prop timeoutHandler

public static prop timeoutHandler: KeyTimeoutHandler

功能:超时处理句柄。

类型:KeyTimeoutHandler

prop name

public prop name: String

功能:超时处理句柄的名称。

类型:String

struct KeyVerbose

public struct KeyVerbose <: KeyFor<Bool> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop verbose

public static prop verbose: Verbose

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct KeyWarmup

public struct KeyWarmup <: KeyFor<Int64> & KeyFor<Duration> {}

功能:用于在 Configuration 中作为对应配置项的键值

父类型:

prop warmup

public static prop warmup: Warmup

功能:配置项的键值。

prop name

public prop name: String

功能:配置项的键值的名称。

struct MeasurementInfo

public struct MeasurementInfo {
    public let conversionTable: MeasurementUnitTable,
    public let name: String,
    public let textDescription: String
}

功能:存储测量信息的结构体。

prop conversionTable

prop conversionTable: MeasurementUnitTable

功能:用于在性能测试报告中构建测量值的表示。 包含测量单位的边界对。 根据值的边界,使用最合适的单位。 对于 CSV 格式报告,始终选择下限以简化结果处理。 默认值为 [(1.0, "")]

类型:MeasurementUnitTable

prop name

prop name: String

功能:当前 Measurement 类型的唯一显示名称。 有助于区分报告表中的不同测量类型。 默认值为 Measurement

类型:String

prop textDescription

prop textDescription: String

功能:描述此测量的简单文本将显示在某些报告中。

类型:String

struct Perf

public struct Perf <: Measurement {
    public init()
    public Perf(counter: PerfCounter)
}

功能:使用linux 系统调用 perf_event_open 测量各种硬件和软件 CPU 计数器。仅在 Linux 上可用。

父类型:

prop conversionTable

prop conversionTable: MeasurementUnitTable

功能:提供对应 CPU 计数器的换算表。

类型:MeasurementUnitTable

prop name

prop name: String

功能:为当前 CPU 计数器提供唯一的显示名称,例如:Perf(cycles)

类型:String

prop textDescription

prop textDescription: String

功能:描述此测量的简单文本将显示在某些报告中。

类型:String

init()

public init()

功能:使用 CPU 周期计数器的默认构造函数。

Perf(PerfCounter)

public Perf(counter: PerfCounter)

功能:指定要测量的 CPU 计数器的构造函数。

参数:

func measure()

public func measure(): Float64

功能:返回指定 CPU 计数器的值。

返回值:

  • Float64 - 计算得到的数据,用于统计分析。

func setup()

func setup()

功能:此 CPU 计数器的初始化例程。在每个基准步骤之前调用。

struct RelativeDelta<T>

public struct RelativeDelta<T> {
    public RelativeDelta(let absolute!: T, let relative!: T) {}
}

功能:对于浮点类型,提供相对的 delta 数据类型来做近似相等的计算。计算公式如下。

$$|x - y| <= absolute + relative * max(abs(x), abs(y))$$

RelativeDelta(T, T)

public RelativeDelta(let absolute!: T, let relative!: T)

功能:RelativeDelta 的主构造函数。

参数:

  • absolute!: T - 绝对比较部分的 delta 值。
  • relative!: T - 相对比较部分的 delta 值。

struct TestCaseInfo

public struct TestCaseInfo {
    public let groupName: String
    public let suiteName: String
    public let caseName: String
}

功能:当前正在运行的测试用例的信息。通常在动态 API 的超时处理句柄中被使用。

let caseName

public let caseName: String

功能:用例名称。

类型:String

let groupName

public let groupName: String

功能:用例的测试组名称。

类型:String

let suiteName

public let suiteName: String

功能:用例的测试套名称。

类型:String

struct TimeNow

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

功能:Measurement 的实现,用于测量执行一个函数所花费的时间。

父类型:

prop conversionTable

prop conversionTable: MeasurementUnitTable

功能:提供当前时间的单位换算表。 例如 [(1.0, "ns"), (1e3, "us"), (1e6, "ms"), (1e9, "s")]

类型:MeasurementUnitTable

prop name

prop name: String

功能:提供当前时间单位唯一的显示名称,例如:Duration(ns)Duration(s)

类型:String

prop textDescription

prop textDescription: String

功能:描述此测量的简单文本将显示在某些报告中。

类型:String

init()

public init()

功能:自动选择输出格式的默认构造函数。

init(?TimeUnit)

public init(unit: ?TimeUnit)

功能: unit 参数用于指定打印结果时将使用的时间单位。

参数:

  • unit: ?TimeUnit - 指定的时间单位。

func measure()

public func measure(): Float64

功能:获取当前时间用于统计分析。

返回值:

  • Float64 - 计算得到的数据,用于统计分析。