1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
17 template <class ValueType
>
21 mutable std::mt19937_64 rng
{std::random_device
{}()};
23 void run(benchmark::State
& state
) const {
24 runOpOnCopies
<ValueType
>(state
, Quantity
, Order::Ascending
, BatchSize::CountBatch
, [&](auto& Copy
) {
25 auto result
= std::lower_bound(Copy
.begin(), Copy
.end(), Copy
[rng() % Copy
.size()]);
26 benchmark::DoNotOptimize(result
);
30 std::string
name() const { return "BM_LowerBound" + ValueType::name() + "_" + std::to_string(Quantity
); }
34 int main(int argc
, char** argv
) {
35 benchmark::Initialize(&argc
, argv
);
36 if (benchmark::ReportUnrecognizedArguments(argc
, argv
))
38 makeCartesianProductBenchmark
<LowerBound
, AllValueTypes
>(Quantities
);
39 benchmark::RunSpecifiedBenchmarks();