diff --git a/Sources/CollectionsBenchmark/Basics/Measurement.swift b/Sources/CollectionsBenchmark/Basics/Measurement.swift new file mode 100644 index 0000000..72d938d --- /dev/null +++ b/Sources/CollectionsBenchmark/Basics/Measurement.swift @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift Collections open source project +// +// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + +/// A point in the document coordinate system, i.e., a pair of size and +/// time values. +public struct Measurement: Hashable, Codable { + public let size: Size + public let time: Time + + public init(size: Size, time: Time) { + self.size = size + self.time = time + } +} diff --git a/Sources/CollectionsBenchmark/Basics/TaskResults.swift b/Sources/CollectionsBenchmark/Basics/TaskResults.swift index 19a361b..1a2c4fe 100644 --- a/Sources/CollectionsBenchmark/Basics/TaskResults.swift +++ b/Sources/CollectionsBenchmark/Basics/TaskResults.swift @@ -167,14 +167,14 @@ extension TaskResults { for statistic: Sample.Statistic, percentile: Double, amortizedTime: Bool - ) -> Curve { - var curve = Curve() + ) -> Curve { + var curve = Curve() for (size, sample) in _samples { let sample = sample.discardingPercentile(above: percentile) guard let time = sample[statistic] ?? sample[.mean] else { continue } let t = amortizedTime ? time.amortized(over: size) : time - curve.points.append(BenchmarkResults.Measurement(size: size, time: t)) + curve.points.append(Measurement(size: size, time: t)) } return curve } diff --git a/Sources/CollectionsBenchmark/Charts/Band.swift b/Sources/CollectionsBenchmark/Charts/Band.swift index 9a094f5..cf112a0 100644 --- a/Sources/CollectionsBenchmark/Charts/Band.swift +++ b/Sources/CollectionsBenchmark/Charts/Band.swift @@ -90,7 +90,7 @@ extension Band { } } -extension Band where Element == Curve { +extension Band where Element == Curve { var sizeRange: ClosedRange? { _union(bottom.sizeRange, _union(center.sizeRange, top.sizeRange)) } diff --git a/Sources/CollectionsBenchmark/Charts/Chart.swift b/Sources/CollectionsBenchmark/Charts/Chart.swift index 37ff9e2..f72f2b1 100644 --- a/Sources/CollectionsBenchmark/Charts/Chart.swift +++ b/Sources/CollectionsBenchmark/Charts/Chart.swift @@ -13,8 +13,6 @@ import Foundation /// The data for a benchmark chart in a nice preprocessed format. public struct Chart { - public typealias Measurement = BenchmarkResults.Measurement - public let options: Options public let sizeScale: ChartScale public let timeScale: ChartScale diff --git a/Sources/CollectionsBenchmark/Charts/Curve.swift b/Sources/CollectionsBenchmark/Charts/Curve.swift index c50b23e..1635236 100644 --- a/Sources/CollectionsBenchmark/Charts/Curve.swift +++ b/Sources/CollectionsBenchmark/Charts/Curve.swift @@ -43,7 +43,7 @@ extension Curve { } } -extension Curve where Point == BenchmarkResults.Measurement { +extension Curve where Point == Measurement { var sizeRange: ClosedRange? { guard !points.isEmpty else { return nil } let min = points.min(by: { $0.size < $1.size }) @@ -60,18 +60,6 @@ extension Curve where Point == BenchmarkResults.Measurement { } extension BenchmarkResults { - /// A point in the document coordinate system, i.e., a pair of size and - /// time values. - public struct Measurement: Hashable, Codable { - public let size: Size - public let time: Time - - public init(size: Size, time: Time) { - self.size = size - self.time = time - } - } - public func curve(id: TaskID, statistic: Sample.Statistic) -> Curve { let points: [Measurement] = self[id: id].compactMap { (size, sample) in guard let time = sample[statistic] else { return nil } diff --git a/Sources/CollectionsBenchmark/Compatibility/Compatibility.swift b/Sources/CollectionsBenchmark/Compatibility/Compatibility.swift new file mode 100644 index 0000000..4c70900 --- /dev/null +++ b/Sources/CollectionsBenchmark/Compatibility/Compatibility.swift @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift Collections open source project +// +// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + +extension BenchmarkResults { + // Deprecated since 0.0.2 + @available(*, deprecated, renamed: "Measurement") + public typealias Point = Measurement +}