1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include <algorithm>
10
11#include "common.h"
12
13namespace {
14template <class ValueType, class Order>
15struct RangesPushHeap {
16 size_t Quantity;
17
18 void run(benchmark::State& state) const {
19 runOpOnCopies<ValueType>(state, Quantity, Order(), BatchSize::CountElements, [](auto& Copy) {
20 for (auto I = Copy.begin(), E = Copy.end(); I != E; ++I) {
21 std::ranges::push_heap(Copy.begin(), I + 1);
22 }
23 });
24 }
25
26 bool skip() const { return Order() == ::Order::Heap; }
27
28 std::string name() const {
29 return "BM_RangesPushHeap" + ValueType::name() + Order::name() + "_" + std::to_string(val: Quantity);
30 };
31};
32} // namespace
33
34int main(int argc, char** argv) {
35 benchmark::Initialize(argc: &argc, argv);
36 if (benchmark::ReportUnrecognizedArguments(argc, argv))
37 return 1;
38 makeCartesianProductBenchmark<RangesPushHeap, AllValueTypes, AllOrders>(A: Quantities);
39 benchmark::RunSpecifiedBenchmarks();
40}
41

source code of libcxx/benchmarks/algorithms/ranges_push_heap.bench.cpp