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 //===----------------------------------------------------------------------===//
10 #include <benchmark/benchmark.h>
15 static void bm_vector_bool_count(benchmark::State
& state
) {
16 std::vector
<bool> vec1(state
.range(), false);
18 for (auto _
: state
) {
19 benchmark::DoNotOptimize(vec1
);
20 benchmark::DoNotOptimize(std::count(vec1
.begin(), vec1
.end(), true));
23 BENCHMARK(bm_vector_bool_count
)->DenseRange(1, 8)->Range(16, 1 << 20);
25 static void bm_vector_bool_ranges_count(benchmark::State
& state
) {
26 std::vector
<bool> vec1(state
.range(), false);
28 for (auto _
: state
) {
29 benchmark::DoNotOptimize(vec1
);
30 benchmark::DoNotOptimize(std::ranges::count(vec1
.begin(), vec1
.end(), true));
33 BENCHMARK(bm_vector_bool_ranges_count
)->DenseRange(1, 8)->Range(16, 1 << 20);