Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

ldionne
Copy link
Member

@ldionne ldionne commented Sep 12, 2025

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).

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).
@ldionne ldionne requested a review from a team as a code owner September 12, 2025 13:25
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Sep 12, 2025
@llvmbot
Copy link
Member

llvmbot commented Sep 12, 2025

@llvm/pr-subscribers-libcxx

Author: Louis Dionne (ldionne)

Changes

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).


Full diff: https://github.com/llvm/llvm-project/pull/158290.diff

2 Files Affected:

  • (modified) libcxx/test/benchmarks/filesystem.bench.cpp (+9-22)
  • (modified) libcxx/utils/parse-google-benchmark-results (+2)
diff --git a/libcxx/test/benchmarks/filesystem.bench.cpp b/libcxx/test/benchmarks/filesystem.bench.cpp
index c058a5d41a150..61d14a453e72f 100644
--- a/libcxx/test/benchmarks/filesystem.bench.cpp
+++ b/libcxx/test/benchmarks/filesystem.bench.cpp
@@ -30,9 +30,8 @@ void BM_PathConstructString(benchmark::State& st, GenInputs gen) {
     const path P(PP.native());
     benchmark::DoNotOptimize(P.native().data());
   }
-  st.SetComplexityN(st.range(0));
 }
-BENCHMARK_CAPTURE(BM_PathConstructString, large_string, getRandomStringInputs)->Range(8, TestNumInputs)->Complexity();
+BENCHMARK_CAPTURE(BM_PathConstructString, large_string, getRandomStringInputs)->Range(8, TestNumInputs);
 
 template <class GenInputs>
 void BM_PathConstructCStr(benchmark::State& st, GenInputs gen) {
@@ -66,7 +65,6 @@ void BM_PathConstructIter(benchmark::State& st, GenInputs gen) {
     const path P(Start, End);
     benchmark::DoNotOptimize(P.native().data());
   }
-  st.SetComplexityN(st.range(0));
 }
 template <class GenInputs>
 void BM_PathConstructInputIter(benchmark::State& st, GenInputs gen) {
@@ -77,11 +75,9 @@ void BM_PathConstructForwardIter(benchmark::State& st, GenInputs gen) {
   BM_PathConstructIter<forward_iterator>(st, gen);
 }
 BENCHMARK_CAPTURE(BM_PathConstructInputIter, large_string, getRandomStringInputs)
-    ->Range(8, TestNumInputs)
-    ->Complexity();
+    ->Range(8, TestNumInputs);
 BENCHMARK_CAPTURE(BM_PathConstructForwardIter, large_string, getRandomStringInputs)
-    ->Range(8, TestNumInputs)
-    ->Complexity();
+    ->Range(8, TestNumInputs);
 
 template <class GenInputs>
 void BM_PathIterateMultipleTimes(benchmark::State& st, GenInputs gen) {
@@ -97,11 +93,9 @@ void BM_PathIterateMultipleTimes(benchmark::State& st, GenInputs gen) {
     }
     benchmark::ClobberMemory();
   }
-  st.SetComplexityN(st.range(0));
 }
 BENCHMARK_CAPTURE(BM_PathIterateMultipleTimes, iterate_elements, getRandomStringInputs)
-    ->Range(8, TestNumInputs)
-    ->Complexity();
+    ->Range(8, TestNumInputs);
 
 template <class GenInputs>
 void BM_PathIterateOnce(benchmark::State& st, GenInputs gen) {
@@ -118,9 +112,8 @@ void BM_PathIterateOnce(benchmark::State& st, GenInputs gen) {
     }
     benchmark::ClobberMemory();
   }
-  st.SetComplexityN(st.range(0));
 }
-BENCHMARK_CAPTURE(BM_PathIterateOnce, iterate_elements, getRandomStringInputs)->Range(8, TestNumInputs)->Complexity();
+BENCHMARK_CAPTURE(BM_PathIterateOnce, iterate_elements, getRandomStringInputs)->Range(8, TestNumInputs);
 
 template <class GenInputs>
 void BM_PathIterateOnceBackwards(benchmark::State& st, GenInputs gen) {
@@ -160,16 +153,13 @@ void BM_LexicallyNormal(benchmark::State& st, GenInput gen, size_t PathLen) {
   while (st.KeepRunning()) {
     benchmark::DoNotOptimize(In.lexically_normal());
   }
-  st.SetComplexityN(st.range(0));
 }
 BENCHMARK_CAPTURE(BM_LexicallyNormal, small_path, getRandomPaths, /*PathLen*/ 5)
     ->RangeMultiplier(2)
-    ->Range(2, 256)
-    ->Complexity();
+    ->Range(2, 256);
 BENCHMARK_CAPTURE(BM_LexicallyNormal, large_path, getRandomPaths, /*PathLen*/ 32)
     ->RangeMultiplier(2)
-    ->Range(2, 256)
-    ->Complexity();
+    ->Range(2, 256);
 
 template <class GenInput>
 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) {
   for (auto _ : st) {
     benchmark::DoNotOptimize(TargetPath.lexically_relative(BasePath));
   }
-  st.SetComplexityN(st.range(0));
 }
 BENCHMARK_CAPTURE(BM_LexicallyRelative, small_path, getRandomPaths, /*PathLen*/ 5)
     ->RangeMultiplier(2)
-    ->Range(2, 256)
-    ->Complexity();
+    ->Range(2, 256);
 BENCHMARK_CAPTURE(BM_LexicallyRelative, large_path, getRandomPaths, /*PathLen*/ 32)
     ->RangeMultiplier(2)
-    ->Range(2, 256)
-    ->Complexity();
+    ->Range(2, 256);
 
 BENCHMARK_MAIN();
diff --git a/libcxx/utils/parse-google-benchmark-results b/libcxx/utils/parse-google-benchmark-results
index 280c8045db6c9..86d59bb522a4d 100755
--- a/libcxx/utils/parse-google-benchmark-results
+++ b/libcxx/utils/parse-google-benchmark-results
@@ -26,6 +26,8 @@ def main(argv):
     for file in args.filename:
         js = json.load(file)
         for bm in js['benchmarks']:
+            if args.timing not in bm:
+                raise RuntimeError(f'Benchmark does not contain key for {args.timing}: {bm}')
             row = [bm['name'], bm[args.timing]]
             rows.append(row)
 

Copy link

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff origin/main HEAD --extensions cpp -- libcxx/test/benchmarks/filesystem.bench.cpp

⚠️
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing origin/main to the base branch/commit you want to compare against.
⚠️

View the diff from clang-format here.
diff --git a/libcxx/test/benchmarks/filesystem.bench.cpp b/libcxx/test/benchmarks/filesystem.bench.cpp
index 61d14a453..8b1af4519 100644
--- a/libcxx/test/benchmarks/filesystem.bench.cpp
+++ b/libcxx/test/benchmarks/filesystem.bench.cpp
@@ -74,10 +74,8 @@ template <class GenInputs>
 void BM_PathConstructForwardIter(benchmark::State& st, GenInputs gen) {
   BM_PathConstructIter<forward_iterator>(st, gen);
 }
-BENCHMARK_CAPTURE(BM_PathConstructInputIter, large_string, getRandomStringInputs)
-    ->Range(8, TestNumInputs);
-BENCHMARK_CAPTURE(BM_PathConstructForwardIter, large_string, getRandomStringInputs)
-    ->Range(8, TestNumInputs);
+BENCHMARK_CAPTURE(BM_PathConstructInputIter, large_string, getRandomStringInputs)->Range(8, TestNumInputs);
+BENCHMARK_CAPTURE(BM_PathConstructForwardIter, large_string, getRandomStringInputs)->Range(8, TestNumInputs);
 
 template <class GenInputs>
 void BM_PathIterateMultipleTimes(benchmark::State& st, GenInputs gen) {
@@ -94,8 +92,7 @@ void BM_PathIterateMultipleTimes(benchmark::State& st, GenInputs gen) {
     benchmark::ClobberMemory();
   }
 }
-BENCHMARK_CAPTURE(BM_PathIterateMultipleTimes, iterate_elements, getRandomStringInputs)
-    ->Range(8, TestNumInputs);
+BENCHMARK_CAPTURE(BM_PathIterateMultipleTimes, iterate_elements, getRandomStringInputs)->Range(8, TestNumInputs);
 
 template <class GenInputs>
 void BM_PathIterateOnce(benchmark::State& st, GenInputs gen) {
@@ -154,12 +151,8 @@ void BM_LexicallyNormal(benchmark::State& st, GenInput gen, size_t PathLen) {
     benchmark::DoNotOptimize(In.lexically_normal());
   }
 }
-BENCHMARK_CAPTURE(BM_LexicallyNormal, small_path, getRandomPaths, /*PathLen*/ 5)
-    ->RangeMultiplier(2)
-    ->Range(2, 256);
-BENCHMARK_CAPTURE(BM_LexicallyNormal, large_path, getRandomPaths, /*PathLen*/ 32)
-    ->RangeMultiplier(2)
-    ->Range(2, 256);
+BENCHMARK_CAPTURE(BM_LexicallyNormal, small_path, getRandomPaths, /*PathLen*/ 5)->RangeMultiplier(2)->Range(2, 256);
+BENCHMARK_CAPTURE(BM_LexicallyNormal, large_path, getRandomPaths, /*PathLen*/ 32)->RangeMultiplier(2)->Range(2, 256);
 
 template <class GenInput>
 void BM_LexicallyRelative(benchmark::State& st, GenInput gen, size_t PathLen) {
@@ -171,11 +164,7 @@ void BM_LexicallyRelative(benchmark::State& st, GenInput gen, size_t PathLen) {
     benchmark::DoNotOptimize(TargetPath.lexically_relative(BasePath));
   }
 }
-BENCHMARK_CAPTURE(BM_LexicallyRelative, small_path, getRandomPaths, /*PathLen*/ 5)
-    ->RangeMultiplier(2)
-    ->Range(2, 256);
-BENCHMARK_CAPTURE(BM_LexicallyRelative, large_path, getRandomPaths, /*PathLen*/ 32)
-    ->RangeMultiplier(2)
-    ->Range(2, 256);
+BENCHMARK_CAPTURE(BM_LexicallyRelative, small_path, getRandomPaths, /*PathLen*/ 5)->RangeMultiplier(2)->Range(2, 256);
+BENCHMARK_CAPTURE(BM_LexicallyRelative, large_path, getRandomPaths, /*PathLen*/ 32)->RangeMultiplier(2)->Range(2, 256);
 
 BENCHMARK_MAIN();

@ldionne
Copy link
Member Author

ldionne commented Sep 12, 2025

/libcxx-bot benchmark libcxx/test/benchmarks/filesystem.bench.cpp

Benchmark results:
Benchmark                                            Baseline    Candidate    Difference    % Difference
-------------------------------------------------  ----------  -----------  ------------  --------------
BM_LexicallyNormal/large_path/128                     7663.25      7696.38         33.13            0.43
BM_LexicallyNormal/large_path/16                       989.67       986.67         -3.00           -0.30
BM_LexicallyNormal/large_path/2                        133.88       131.17         -2.71           -2.02
BM_LexicallyNormal/large_path/256                    15237.04     16279.94       1042.89            6.84
BM_LexicallyNormal/large_path/32                      1947.16      1965.45         18.28            0.94
BM_LexicallyNormal/large_path/4                        272.26       269.45         -2.81           -1.03
BM_LexicallyNormal/large_path/64                      3870.96      3927.72         56.75            1.47
BM_LexicallyNormal/large_path/8                        519.97       517.38         -2.59           -0.50
BM_LexicallyNormal/small_path/128                     4421.40      4182.78       -238.62           -5.40
BM_LexicallyNormal/small_path/16                       537.68       535.97         -1.70           -0.32
BM_LexicallyNormal/small_path/2                         75.19        73.34         -1.85           -2.46
BM_LexicallyNormal/small_path/256                     8282.60      8312.43         29.83            0.36
BM_LexicallyNormal/small_path/32                      1034.65      1042.73          8.08            0.78
BM_LexicallyNormal/small_path/4                        149.31       148.52         -0.79           -0.53
BM_LexicallyNormal/small_path/64                      2109.29      2103.39         -5.90           -0.28
BM_LexicallyNormal/small_path/8                        286.24       283.27         -2.97           -1.04
BM_LexicallyRelative/large_path/128                  11269.21     11073.43       -195.78           -1.74
BM_LexicallyRelative/large_path/16                    1401.39      1400.84         -0.55           -0.04
BM_LexicallyRelative/large_path/2                      216.81       214.16         -2.65           -1.22
BM_LexicallyRelative/large_path/256                  22073.60     22130.42         56.82            0.26
BM_LexicallyRelative/large_path/32                    2837.72      2882.10         44.38            1.56
BM_LexicallyRelative/large_path/4                      415.86       415.64         -0.21           -0.05
BM_LexicallyRelative/large_path/64                    5625.84      5624.70         -1.14           -0.02
BM_LexicallyRelative/large_path/8                      734.57       746.28         11.70            1.59
BM_LexicallyRelative/small_path/128                   6639.92      6653.69         13.77            0.21
BM_LexicallyRelative/small_path/16                     900.86       893.36         -7.50           -0.83
BM_LexicallyRelative/small_path/2                      132.03       135.84          3.81            2.88
BM_LexicallyRelative/small_path/256                  13200.77     13201.81          1.04            0.01
BM_LexicallyRelative/small_path/32                    1729.12      1713.33        -15.78           -0.91
BM_LexicallyRelative/small_path/4                      245.40       245.44          0.04            0.02
BM_LexicallyRelative/small_path/64                    3352.93      3353.03          0.10            0.00
BM_LexicallyRelative/small_path/8                      467.16       467.71          0.55            0.12
BM_PathConstructCStr/large_string/1024               60019.50     60452.17        432.67            0.72
BM_PathConstructForwardIter/large_string/1024        73790.94     72767.96      -1022.98           -1.39
BM_PathConstructForwardIter/large_string/512         38891.96     36431.53      -2460.42           -6.33
BM_PathConstructForwardIter/large_string/64           2820.02      2797.74        -22.28           -0.79
BM_PathConstructForwardIter/large_string/8            2956.69      2955.95         -0.74           -0.02
BM_PathConstructInputIter/large_string/1024        2022434.93   2065907.93      43473.00            2.15
BM_PathConstructInputIter/large_string/512         1073821.27   1081657.22       7835.96            0.73
BM_PathConstructInputIter/large_string/64           128603.32    133677.39       5074.07            3.95
BM_PathConstructInputIter/large_string/8             13773.48     14275.43        501.96            3.64
BM_PathConstructString/large_string/1024             46351.93     46066.74       -285.19           -0.62
BM_PathConstructString/large_string/512              23767.74     23177.47       -590.26           -2.48
BM_PathConstructString/large_string/64                1504.29      1550.41         46.12            3.07
BM_PathConstructString/large_string/8                  157.18       156.95         -0.23           -0.14
BM_PathIterateMultipleTimes/iterate_elements/1024   411079.75    412310.30       1230.55            0.30
BM_PathIterateMultipleTimes/iterate_elements/512    203857.86    203691.72       -166.14           -0.08
BM_PathIterateMultipleTimes/iterate_elements/64      26309.28     25332.86       -976.42           -3.71
BM_PathIterateMultipleTimes/iterate_elements/8        3262.79      3166.39        -96.40           -2.95
BM_PathIterateOnce/iterate_elements/1024            454810.67    450394.32      -4416.35           -0.97
BM_PathIterateOnce/iterate_elements/512             427136.32    419788.26      -7348.05           -1.72
BM_PathIterateOnce/iterate_elements/64               27909.55     26731.28      -1178.27           -4.22
BM_PathIterateOnce/iterate_elements/8                 3494.98      3335.03       -159.94           -4.58
BM_PathIterateOnceBackwards/iterate_elements/1024   458797.13    459093.41        296.29            0.06

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants