Skip to content

Commit 1a382ab

Browse files
committed
[benchmark] Warn about incorrect --memory use
1 parent a61a756 commit 1a382ab

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

benchmark/utils/DriverUtils.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,16 @@ struct TestConfig {
141141
tags: c.tags ?? [],
142142
skipTags: c.skipTags ?? [.unstable, .skip])
143143

144+
if logMemory && tests.count > 1 {
145+
print(
146+
"""
147+
warning: The memory usage of a test, reported as the change in MAX_RSS,
148+
is based on measuring the peak memory used by the whole process.
149+
These results are meaningful only when running a single test,
150+
not in the batch mode!
151+
""")
152+
}
153+
144154
if verbose {
145155
let testList = tests.map({ $0.1.name }).joined(separator: ", ")
146156
print("""
@@ -186,7 +196,7 @@ struct TestConfig {
186196
func byNamesOrIndices(b: BenchmarkInfo) -> Bool {
187197
return specifiedTests.contains(b.name) ||
188198
specifiedTests.contains(indices[b.name]!)
189-
} // !! "All registeredBenchmarks have been assigned an index"
199+
} // !! "`allTests` have been assigned an index"
190200
return allTests
191201
.filter(specifiedTests.isEmpty ? byTags : byNamesOrIndices)
192202
.map { (index: indices[$0.name]!, info: $0) }

test/benchmark/Benchmark_O.test.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,14 @@ BADSKIPTAG: error: 'bogus' is not a valid 'BenchmarkCategory'
188188
189189
````
190190

191+
Measuring memory use of a test with our method is valid only for single test.
192+
193+
````
194+
RUN: %Benchmark_O 1 2 --memory --list \
195+
RUN: 2>&1 | %FileCheck %s --check-prefix WARNMEMORY
196+
WARNMEMORY: warning:
197+
````
198+
191199
## Usage
192200

193201
````

0 commit comments

Comments
 (0)