diff options
author | Konstantin Varlamov <varconst@apple.com> | 2022-06-16 15:20:53 -0700 |
---|---|---|
committer | Konstantin Varlamov <varconst@apple.com> | 2022-06-16 15:21:06 -0700 |
commit | ff3989e6ae740a9b3adaad0e2bf7691ffd6dad12 (patch) | |
tree | 0f0b28bb899a2266e8c07a477053bf26f39567a5 /libcxx/benchmarks | |
parent | dba2ff500d5b29f2d18b93aed5caa5b4ef7c94dd (diff) | |
download | llvm-ff3989e6ae740a9b3adaad0e2bf7691ffd6dad12.tar.gz |
[libc++][ranges] Implement `ranges::sort`.
Differential Revision: https://reviews.llvm.org/D127557
Diffstat (limited to 'libcxx/benchmarks')
-rw-r--r-- | libcxx/benchmarks/CMakeLists.txt | 1 | ||||
-rw-r--r-- | libcxx/benchmarks/algorithms/ranges_sort.bench.cpp | 39 |
2 files changed, 40 insertions, 0 deletions
diff --git a/libcxx/benchmarks/CMakeLists.txt b/libcxx/benchmarks/CMakeLists.txt index 9fa57f86aefe..bc5052da854f 100644 --- a/libcxx/benchmarks/CMakeLists.txt +++ b/libcxx/benchmarks/CMakeLists.txt @@ -166,6 +166,7 @@ set(BENCHMARK_TESTS algorithms/min_max_element.bench.cpp algorithms/pop_heap.bench.cpp algorithms/push_heap.bench.cpp + algorithms/ranges_sort.bench.cpp algorithms/sort.bench.cpp algorithms/sort_heap.bench.cpp algorithms/stable_sort.bench.cpp diff --git a/libcxx/benchmarks/algorithms/ranges_sort.bench.cpp b/libcxx/benchmarks/algorithms/ranges_sort.bench.cpp new file mode 100644 index 000000000000..b9299d3fe144 --- /dev/null +++ b/libcxx/benchmarks/algorithms/ranges_sort.bench.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include <algorithm> + +#include "common.h" + +namespace { +template <class ValueType, class Order> +struct Sort { + size_t Quantity; + + void run(benchmark::State& state) const { + runOpOnCopies<ValueType>( + state, Quantity, Order(), BatchSize::CountElements, + [](auto& Copy) { std::ranges::sort(Copy); }); + } + + bool skip() const { return Order() == ::Order::Heap; } + + std::string name() const { + return "BM_RangesSort" + ValueType::name() + Order::name() + "_" + + std::to_string(Quantity); + } +}; +} // namespace + +int main(int argc, char** argv) { + benchmark::Initialize(&argc, argv); + if (benchmark::ReportUnrecognizedArguments(argc, argv)) + return 1; + makeCartesianProductBenchmark<Sort, AllValueTypes, AllOrders>(Quantities); + benchmark::RunSpecifiedBenchmarks(); +} |