Skip to content

Commit d68b802

Browse files
fix(examples): remove compilation warning about unused variables
1 parent d5b4b77 commit d68b802

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

examples/google_benchmark_cmake/fixture_bench.hpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@
44
#ifndef FIXTURE_BENCH_HPP
55
#define FIXTURE_BENCH_HPP
66

7-
87
#include <benchmark/benchmark.h>
98

109
namespace example_namespace {
1110

1211
class MyFixture : public benchmark::Fixture {
13-
public:
14-
void SetUp(::benchmark::State &state) {}
12+
public:
13+
void SetUp(::benchmark::State &state) { (void)state; }
1514

16-
void TearDown(::benchmark::State &state) {}
15+
void TearDown(::benchmark::State &state) { (void)state; }
1716
};
1817
BENCHMARK_F(MyFixture, FooTest)(benchmark::State &st) {
1918
for (auto _ : st) {
@@ -28,7 +27,8 @@ BENCHMARK_REGISTER_F(MyFixture, BarTest);
2827
//
2928
//
3029

31-
template <typename T> class MyTemplatedFixture : public benchmark::Fixture {};
30+
template <typename T>
31+
class MyTemplatedFixture : public benchmark::Fixture {};
3232
BENCHMARK_TEMPLATE_F(MyTemplatedFixture, IntTest, int)(benchmark::State &st) {
3333
for (auto _ : st) {
3434
}
@@ -43,7 +43,8 @@ BENCHMARK_REGISTER_F(MyTemplatedFixture, DoubleTest);
4343
//
4444
//
4545

46-
template <typename T> class MyTemplate1 : public benchmark::Fixture {};
46+
template <typename T>
47+
class MyTemplate1 : public benchmark::Fixture {};
4748
BENCHMARK_TEMPLATE1_DEFINE_F(MyTemplate1, TestA, int)(benchmark::State &st) {
4849
for (auto _ : st) {
4950
}
@@ -53,13 +54,15 @@ BENCHMARK_REGISTER_F(MyTemplate1, TestA);
5354
//
5455
//
5556

56-
template <typename T, typename U> class MyTemplate2 : public benchmark::Fixture {};
57-
BENCHMARK_TEMPLATE2_DEFINE_F(MyTemplate2, TestB, int, double)(benchmark::State &st) {
57+
template <typename T, typename U>
58+
class MyTemplate2 : public benchmark::Fixture {};
59+
BENCHMARK_TEMPLATE2_DEFINE_F(MyTemplate2, TestB, int,
60+
double)(benchmark::State &st) {
5861
for (auto _ : st) {
5962
}
6063
}
6164
BENCHMARK_REGISTER_F(MyTemplate2, TestB);
6265

63-
}
66+
} // namespace example_namespace
6467

6568
#endif

examples/google_benchmark_cmake/main.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
#include "fixture_bench.hpp"
2-
#include "template_bench.hpp"
31
#include <benchmark/benchmark.h>
2+
43
#include <cstring>
54

5+
#include "fixture_bench.hpp"
6+
#include "template_bench.hpp"
7+
68
template <class... Args>
79
void BM_Capture(benchmark::State &state, Args &&...args) {
810
auto args_tuple = std::make_tuple(std::move(args)...);
11+
(void)args_tuple;
912
for (auto _ : state) {
1013
}
1114
}
@@ -36,8 +39,7 @@ static void BM_memcpy(benchmark::State &state) {
3639
char *src = new char[state.range(0)];
3740
char *dst = new char[state.range(0)];
3841
memset(src, 'x', state.range(0));
39-
for (auto _ : state)
40-
memcpy(dst, src, state.range(0));
42+
for (auto _ : state) memcpy(dst, src, state.range(0));
4143
delete[] src;
4244
delete[] dst;
4345
}

0 commit comments

Comments
 (0)