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 <benchmark/benchmark.h> |
11 | #include <deque> |
12 | |
13 | static void bm_deque_for_each(benchmark::State& state) { |
14 | std::deque<char> vec1(state.range(), '1'); |
15 | for (auto _ : state) { |
16 | benchmark::DoNotOptimize(value&: vec1); |
17 | benchmark::DoNotOptimize( |
18 | value: std::for_each(first: vec1.begin(), last: vec1.end(), f: [](char& v) { v = std::clamp(val: v, lo: (char)10, hi: (char)100); })); |
19 | } |
20 | } |
21 | BENCHMARK(bm_deque_for_each)->DenseRange(start: 1, limit: 8)->Range(start: 16, limit: 1 << 20); |
22 | |
23 | BENCHMARK_MAIN(); |
24 |