[libcxx-commits] [libcxx] [libc++] Avoid string reallocation in `std::filesystem::path::lexically_relative` (PR #152964)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Mon Aug 11 00:41:14 PDT 2025


================
@@ -171,4 +171,25 @@ BENCHMARK_CAPTURE(BM_LexicallyNormal, large_path, getRandomPaths, /*PathLen*/ 32
     ->Range(2, 256)
     ->Complexity();
 
+template <class GenInput>
+void BM_LexicallyRelative(benchmark::State& st, GenInput gen, size_t PathLen) {
+  using fs::path;
+  auto BasePath = gen(st.range(0), PathLen);
+  auto TargetPath = gen(st.range(0), PathLen);
+  benchmark::DoNotOptimize(&BasePath);
+  benchmark::DoNotOptimize(&TargetPath);
+  while (st.KeepRunning()) {
----------------
philnik777 wrote:

We tend to use `auto _ : state` in new benchmarks.

https://github.com/llvm/llvm-project/pull/152964


More information about the libcxx-commits mailing list