[libcxx-commits] [libcxx] [libc++] Rewrite the std::pop_heap benchmark (PR #179911)
via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Feb 5 04:07:12 PST 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- libcxx/test/benchmarks/algorithms/sorting/pop_heap.bench.cpp --diff_from_common_commit
``````````
:warning:
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.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/libcxx/test/benchmarks/algorithms/sorting/pop_heap.bench.cpp b/libcxx/test/benchmarks/algorithms/sorting/pop_heap.bench.cpp
index ad0ca8bff..d545daa12 100644
--- a/libcxx/test/benchmarks/algorithms/sorting/pop_heap.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/sorting/pop_heap.bench.cpp
@@ -18,22 +18,29 @@
int main(int argc, char** argv) {
auto bm = []<class Container>(std::type_identity<Container>, std::string name) {
- benchmark::RegisterBenchmark(name, [](benchmark::State& state) {
- std::size_t size = state.range(0);
-
- Container c;
- std::generate_n(std::back_inserter(c), size, [] { return Generate<typename Container::value_type>::random(); });
-
- while (state.KeepRunningBatch(size)) {
- state.PauseTiming();
- std::make_heap(c.begin(), c.end());
- state.ResumeTiming();
-
- for (auto first = c.begin(), last = c.end(); last != first; --last) {
- std::pop_heap(first, last);
- }
- }
- })->Arg(8)->Arg(1024)->Arg(8192);
+ benchmark::RegisterBenchmark(
+ name,
+ [](benchmark::State& state) {
+ std::size_t size = state.range(0);
+
+ Container c;
+ std::generate_n(std::back_inserter(c), size, [] {
+ return Generate<typename Container::value_type>::random();
+ });
+
+ while (state.KeepRunningBatch(size)) {
+ state.PauseTiming();
+ std::make_heap(c.begin(), c.end());
+ state.ResumeTiming();
+
+ for (auto first = c.begin(), last = c.end(); last != first; --last) {
+ std::pop_heap(first, last);
+ }
+ }
+ })
+ ->Arg(8)
+ ->Arg(1024)
+ ->Arg(8192);
};
bm(std::type_identity<std::vector<int>>{}, "std::pop_heap(vector<int>)");
``````````
</details>
https://github.com/llvm/llvm-project/pull/179911
More information about the libcxx-commits
mailing list