[libcxx-commits] [libcxx] [libc++] Rewrite the std::make_heap benchmark (PR #178696)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Tue Feb 3 06:46:33 PST 2026


================
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+#include <algorithm>
+#include <array>
+#include <cstddef>
+#include <deque>
+#include <string>
+#include <vector>
+
+#include "benchmark/benchmark.h"
+#include "common.h"
+
+int main(int argc, char** argv) {
+  // Benchmark std::make_heap on various types of data
+  //
+  // We perform this benchmark in a batch because we need to restore the
+  // state of the container after the operation.
+  //
+  // Also note that we intentionally don't benchmark the predicated version of the algorithm
+  // because that makes the benchmark run too slowly.
----------------
philnik777 wrote:

I've actually just copied that from `std::sort` and haven't thought about it more. Currently the benchmark takes ~1 minute to run. I think 2x should be fine.

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


More information about the libcxx-commits mailing list