Skip to content

Commit ea80003

Browse files
authored
Merge pull request #24307 from palimondo/legacy-factor-doc
[benchmark] Documentation for legacyFactor
2 parents 6ca706e + e779e06 commit ea80003

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

benchmark/utils/TestsUtils.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,21 @@ public struct BenchmarkInfo {
151151
return _tearDownFunction
152152
}
153153

154+
/// DON'T USE ON NEW BENCHMARKS!
155+
/// Optional `legacyFactor` is a multiplication constant applied to runtime
156+
/// statistics reported in the benchmark summary (it doesn’t affect the
157+
/// individual sample times reported in `--verbose` mode).
158+
///
159+
/// It enables the migration of benchmark suite to smaller workloads (< 1 ms),
160+
/// which are more robust to measurement errors from system under load,
161+
/// while maintaining the continuity of longterm benchmark tracking.
162+
///
163+
/// Most legacy benchmarks had workloads artificially inflated in their main
164+
/// `for` loops with a constant integer factor and the migration consisted of
165+
/// dividing it so that the optimized runtime (-O) was less than 1000 μs and
166+
/// storing the divisor in `legacyFactor`. This effectively only increases the
167+
/// frequency of measurement, gathering more samples that are much less likely
168+
/// to be interrupted by a context switch.
154169
public var legacyFactor: Int?
155170

156171
public init(name: String, runFunction: @escaping (Int) -> (), tags: [BenchmarkCategory],

0 commit comments

Comments
 (0)