Skip to content

Commit d0263f0

Browse files
authored
[libc++] Remove complexity calculations from <filesystem> benchmark (#158290)
Our benchmarks are not really suited for complexity calculation, since that doesn't translate nicely to any of the performance tracking tools we have (including Lit).
1 parent a41660a commit d0263f0

File tree

2 files changed

+11
-22
lines changed

2 files changed

+11
-22
lines changed

libcxx/test/benchmarks/filesystem.bench.cpp

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ void BM_PathConstructString(benchmark::State& st, GenInputs gen) {
3030
const path P(PP.native());
3131
benchmark::DoNotOptimize(P.native().data());
3232
}
33-
st.SetComplexityN(st.range(0));
3433
}
35-
BENCHMARK_CAPTURE(BM_PathConstructString, large_string, getRandomStringInputs)->Range(8, TestNumInputs)->Complexity();
34+
BENCHMARK_CAPTURE(BM_PathConstructString, large_string, getRandomStringInputs)->Range(8, TestNumInputs);
3635

3736
template <class GenInputs>
3837
void BM_PathConstructCStr(benchmark::State& st, GenInputs gen) {
@@ -66,7 +65,6 @@ void BM_PathConstructIter(benchmark::State& st, GenInputs gen) {
6665
const path P(Start, End);
6766
benchmark::DoNotOptimize(P.native().data());
6867
}
69-
st.SetComplexityN(st.range(0));
7068
}
7169
template <class GenInputs>
7270
void BM_PathConstructInputIter(benchmark::State& st, GenInputs gen) {
@@ -77,11 +75,9 @@ void BM_PathConstructForwardIter(benchmark::State& st, GenInputs gen) {
7775
BM_PathConstructIter<forward_iterator>(st, gen);
7876
}
7977
BENCHMARK_CAPTURE(BM_PathConstructInputIter, large_string, getRandomStringInputs)
80-
->Range(8, TestNumInputs)
81-
->Complexity();
78+
->Range(8, TestNumInputs);
8279
BENCHMARK_CAPTURE(BM_PathConstructForwardIter, large_string, getRandomStringInputs)
83-
->Range(8, TestNumInputs)
84-
->Complexity();
80+
->Range(8, TestNumInputs);
8581

8682
template <class GenInputs>
8783
void BM_PathIterateMultipleTimes(benchmark::State& st, GenInputs gen) {
@@ -97,11 +93,9 @@ void BM_PathIterateMultipleTimes(benchmark::State& st, GenInputs gen) {
9793
}
9894
benchmark::ClobberMemory();
9995
}
100-
st.SetComplexityN(st.range(0));
10196
}
10297
BENCHMARK_CAPTURE(BM_PathIterateMultipleTimes, iterate_elements, getRandomStringInputs)
103-
->Range(8, TestNumInputs)
104-
->Complexity();
98+
->Range(8, TestNumInputs);
10599

106100
template <class GenInputs>
107101
void BM_PathIterateOnce(benchmark::State& st, GenInputs gen) {
@@ -118,9 +112,8 @@ void BM_PathIterateOnce(benchmark::State& st, GenInputs gen) {
118112
}
119113
benchmark::ClobberMemory();
120114
}
121-
st.SetComplexityN(st.range(0));
122115
}
123-
BENCHMARK_CAPTURE(BM_PathIterateOnce, iterate_elements, getRandomStringInputs)->Range(8, TestNumInputs)->Complexity();
116+
BENCHMARK_CAPTURE(BM_PathIterateOnce, iterate_elements, getRandomStringInputs)->Range(8, TestNumInputs);
124117

125118
template <class GenInputs>
126119
void BM_PathIterateOnceBackwards(benchmark::State& st, GenInputs gen) {
@@ -160,16 +153,13 @@ void BM_LexicallyNormal(benchmark::State& st, GenInput gen, size_t PathLen) {
160153
while (st.KeepRunning()) {
161154
benchmark::DoNotOptimize(In.lexically_normal());
162155
}
163-
st.SetComplexityN(st.range(0));
164156
}
165157
BENCHMARK_CAPTURE(BM_LexicallyNormal, small_path, getRandomPaths, /*PathLen*/ 5)
166158
->RangeMultiplier(2)
167-
->Range(2, 256)
168-
->Complexity();
159+
->Range(2, 256);
169160
BENCHMARK_CAPTURE(BM_LexicallyNormal, large_path, getRandomPaths, /*PathLen*/ 32)
170161
->RangeMultiplier(2)
171-
->Range(2, 256)
172-
->Complexity();
162+
->Range(2, 256);
173163

174164
template <class GenInput>
175165
void BM_LexicallyRelative(benchmark::State& st, GenInput gen, size_t PathLen) {
@@ -180,15 +170,12 @@ void BM_LexicallyRelative(benchmark::State& st, GenInput gen, size_t PathLen) {
180170
for (auto _ : st) {
181171
benchmark::DoNotOptimize(TargetPath.lexically_relative(BasePath));
182172
}
183-
st.SetComplexityN(st.range(0));
184173
}
185174
BENCHMARK_CAPTURE(BM_LexicallyRelative, small_path, getRandomPaths, /*PathLen*/ 5)
186175
->RangeMultiplier(2)
187-
->Range(2, 256)
188-
->Complexity();
176+
->Range(2, 256);
189177
BENCHMARK_CAPTURE(BM_LexicallyRelative, large_path, getRandomPaths, /*PathLen*/ 32)
190178
->RangeMultiplier(2)
191-
->Range(2, 256)
192-
->Complexity();
179+
->Range(2, 256);
193180

194181
BENCHMARK_MAIN();

libcxx/utils/parse-google-benchmark-results

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ def main(argv):
2626
for file in args.filename:
2727
js = json.load(file)
2828
for bm in js['benchmarks']:
29+
if args.timing not in bm:
30+
raise RuntimeError(f'Benchmark does not contain key for {args.timing}: {bm}')
2931
row = [bm['name'], bm[args.timing]]
3032
rows.append(row)
3133

0 commit comments

Comments
 (0)