Debian Codegraph @

libcxx/benchmarks/algorithms/pstl.stable_sort.bench.cpp

raw
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 #include <execution>
11
12 #include "common.h"
13
14 namespace {
15 template <class ValueType, class Order>
16 struct StableSort {
17 size_t Quantity;
18
19 void run(benchmark::State& state) const {
20 runOpOnCopies<ValueType>(state, Quantity, Order(), BatchSize::CountBatch, [](auto& Copy) {
21 std::stable_sort(std::execution::par, Copy.begin(), Copy.end());
22 });
23 }
24
25 bool skip() const { return Order() == ::Order::Heap; }
26
27 std::string name() const {
28 return "BM_pstl_stable_sort" + ValueType::name() + Order::name() + "/" + std::to_string(Quantity);
29 }
30 };
31 } // namespace
32
33 int main(int argc, char** argv) {
34 benchmark::Initialize(&argc, argv);
35 if (benchmark::ReportUnrecognizedArguments(argc, argv))
36 return 1;
37 makeCartesianProductBenchmark<StableSort, AllValueTypes, AllOrders>(Quantities);
38 benchmark::RunSpecifiedBenchmarks();
39 }