[libcxx-commits] [libcxx] [libcxx] Run std::pop_heap() benchmarks on heap-ordered inputs only (PR #182788)
Aleksei Sidorin via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Feb 22 17:14:48 PST 2026
https://github.com/a-sid created https://github.com/llvm/llvm-project/pull/182788
* std::pop_heap() Standard specification requires it to run on heap-ordered inputs only.
However, it looks like the current version runs it on randomly-ordered inputs,
which makes the benchmark results a bit questionable.
>From 332d4a325423e33a201a3901b60f3843f24afdcd Mon Sep 17 00:00:00 2001
From: Aleksei Sidorin <alexey.v.sidorin at yandex.ru>
Date: Sun, 8 Feb 2026 14:19:48 +0200
Subject: [PATCH] [libcxx] run pop_heap benchmark only on heap-ordered inputs
---
libcxx/test/benchmarks/algorithms/pop_heap.bench.cpp | 6 ++++--
libcxx/test/benchmarks/algorithms/ranges_pop_heap.bench.cpp | 6 ++++--
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/libcxx/test/benchmarks/algorithms/pop_heap.bench.cpp b/libcxx/test/benchmarks/algorithms/pop_heap.bench.cpp
index e4b96a0ae48c7..6b603589150e2 100644
--- a/libcxx/test/benchmarks/algorithms/pop_heap.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/pop_heap.bench.cpp
@@ -13,7 +13,7 @@
#include "common.h"
namespace {
-template <class ValueType>
+template <class ValueType, class Order>
struct PopHeap {
size_t Quantity;
@@ -25,6 +25,8 @@ struct PopHeap {
});
}
+ bool skip() const { return Order() != ::Order::Heap; }
+
std::string name() const { return "BM_PopHeap" + ValueType::name() + "_" + std::to_string(Quantity); };
};
} // namespace
@@ -33,6 +35,6 @@ int main(int argc, char** argv) {
benchmark::Initialize(&argc, argv);
if (benchmark::ReportUnrecognizedArguments(argc, argv))
return 1;
- makeCartesianProductBenchmark<PopHeap, AllValueTypes>(Quantities);
+ makeCartesianProductBenchmark<PopHeap, AllValueTypes, AllOrders>(Quantities);
benchmark::RunSpecifiedBenchmarks();
}
diff --git a/libcxx/test/benchmarks/algorithms/ranges_pop_heap.bench.cpp b/libcxx/test/benchmarks/algorithms/ranges_pop_heap.bench.cpp
index ab3ae6f7c30ae..97d646c8a997a 100644
--- a/libcxx/test/benchmarks/algorithms/ranges_pop_heap.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/ranges_pop_heap.bench.cpp
@@ -13,7 +13,7 @@
#include "common.h"
namespace {
-template <class ValueType>
+template <class ValueType, class Order>
struct RangesPopHeap {
size_t Quantity;
@@ -25,6 +25,8 @@ struct RangesPopHeap {
});
}
+ bool skip() const { return Order() != ::Order::Heap; }
+
std::string name() const { return "BM_RangesPopHeap" + ValueType::name() + "_" + std::to_string(Quantity); };
};
} // namespace
@@ -33,6 +35,6 @@ int main(int argc, char** argv) {
benchmark::Initialize(&argc, argv);
if (benchmark::ReportUnrecognizedArguments(argc, argv))
return 1;
- makeCartesianProductBenchmark<RangesPopHeap, AllValueTypes>(Quantities);
+ makeCartesianProductBenchmark<RangesPopHeap, AllValueTypes, AllOrders>(Quantities);
benchmark::RunSpecifiedBenchmarks();
}
More information about the libcxx-commits
mailing list