Skip to content

Commit 9a19eb2

Browse files
committed
fix: clang-tidy errors in benchmarks
1 parent 100b3db commit 9a19eb2

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

benchmarks/benchmark_features.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static void run_default(benchmark::State& state, Func func, Args... args) {
6969
env.mem_resource = &new_delete_resource;
7070

7171
const auto input = make_random_input(1, state.range(0));
72-
for (auto _ : state) {
72+
for ([[maybe_unused]] auto _ : state) {
7373
auto result = func(env, input, args...);
7474
benchmark::DoNotOptimize(result);
7575
}
@@ -86,7 +86,7 @@ static void run_cached(benchmark::State& state, Func func, Args... args) {
8686
env.cache = cache.get();
8787

8888
const auto input = make_random_input(1, state.range(0));
89-
for (auto _ : state) {
89+
for ([[maybe_unused]] auto _ : state) {
9090
auto result = func(env, input, args...);
9191
benchmark::DoNotOptimize(result);
9292
}
@@ -100,7 +100,7 @@ static void run_monotonic(benchmark::State& state, Func func, Args... args) {
100100
AllocationCounter new_delete_resource{std::pmr::new_delete_resource()};
101101

102102
const auto input = make_random_input(1, state.range(0));
103-
for (auto _ : state) {
103+
for ([[maybe_unused]] auto _ : state) {
104104
state.PauseTiming();
105105
std::pmr::monotonic_buffer_resource buffer_resource{
106106
buffer.data(), buffer.size(), &new_delete_resource
@@ -128,7 +128,7 @@ static void run_pool(benchmark::State& state, Func func, Args... args) {
128128
env.mem_resource = &pool_resource;
129129

130130
const auto input = make_random_input(1, state.range(0));
131-
for (auto _ : state) {
131+
for ([[maybe_unused]] auto _ : state) {
132132
auto result = func(env, input, args...);
133133
benchmark::DoNotOptimize(result);
134134
}

benchmarks/benchmark_hash.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@
99
#include "random.hpp"
1010

1111
static void benchmark_sum(benchmark::State& state) {
12-
const auto vec = make_random_vector<float>(state.range(), -1.0, 1.0);
13-
for (auto _ : state) {
14-
auto sum = std::accumulate(vec.begin(), vec.end(), 0.0f);
12+
const auto vec = make_random_vector<float>(state.range(), -1.0F, 1.0F);
13+
for ([[maybe_unused]] auto _ : state) {
14+
auto sum = std::accumulate(vec.begin(), vec.end(), 0.0F);
1515
benchmark::DoNotOptimize(sum);
1616
}
1717
state.SetItemsProcessed(state.iterations() * state.range(0));
1818
}
1919

2020
static void benchmark_std_hash(benchmark::State& state) {
21-
const auto vec = make_random_vector<float>(state.range(), -1.0, 1.0);
22-
for (auto _ : state) {
21+
const auto vec = make_random_vector<float>(state.range(), -1.0F, 1.0F);
22+
for ([[maybe_unused]] auto _ : state) {
2323
size_t hash = vec.size();
2424
for (auto value : vec) {
2525
hash ^= std::hash<float>{}(value);
@@ -31,8 +31,8 @@ static void benchmark_std_hash(benchmark::State& state) {
3131

3232
template <typename F>
3333
static void benchmark_xxhash(benchmark::State& state, F hash_func) {
34-
const auto vec = make_random_vector<float>(state.range(), -1.0, 1.0);
35-
for (auto _ : state) {
34+
const auto vec = make_random_vector<float>(state.range(), -1.0F, 1.0F);
35+
for ([[maybe_unused]] auto _ : state) {
3636
auto hash = hash_func(vec.data(), vec.size() * sizeof(float), 0 /* seed */);
3737
benchmark::DoNotOptimize(hash);
3838
}

0 commit comments

Comments
 (0)