Skip to content

Commit 1bf3eee

Browse files
committed
feat: add pre-commit-hooks
1 parent 719c41f commit 1bf3eee

File tree

4 files changed

+31
-9
lines changed

4 files changed

+31
-9
lines changed

.pre-commit-config.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
exclude: '^(google_benchmark/.*|core/instrument-hooks/.*|.*/build/.*|build/.*|core/include/valgrind\.h|core/include/callgrind\.h)'
4+
files: ^(core|examples)/.*$
5+
6+
repos:
7+
- repo: https://github.com/pre-commit/pre-commit-hooks
8+
rev: v4.5.0
9+
hooks:
10+
- id: trailing-whitespace
11+
- id: end-of-file-fixer
12+
- id: check-added-large-files
13+
- repo: https://github.com/cpp-linter/cpp-linter-hooks
14+
rev: v0.6.1
15+
hooks:
16+
- id: clang-format
17+
files: \.(cpp|cc|cxx|h|hpp)$
18+

core/src/utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ std::string safe_getenv(const char* var_name);
1010

1111
} // namespace codspeed
1212

13-
#endif // CODSPEED_UTILS_H
13+
#endif // CODSPEED_UTILS_H

examples/google_benchmark_cmake/fixture_bench.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ BENCHMARK_TEMPLATE_F(MyTemplatedFixture, IntTest, int)(benchmark::State &st) {
3333
for (auto _ : st) {
3434
}
3535
}
36-
BENCHMARK_TEMPLATE_DEFINE_F(MyTemplatedFixture, DoubleTest,
37-
double)(benchmark::State &st) {
36+
BENCHMARK_TEMPLATE_DEFINE_F(MyTemplatedFixture, DoubleTest, double)
37+
(benchmark::State &st) {
3838
for (auto _ : st) {
3939
}
4040
}
@@ -56,8 +56,8 @@ BENCHMARK_REGISTER_F(MyTemplate1, TestA);
5656

5757
template <typename T, typename U>
5858
class MyTemplate2 : public benchmark::Fixture {};
59-
BENCHMARK_TEMPLATE2_DEFINE_F(MyTemplate2, TestB, int,
60-
double)(benchmark::State &st) {
59+
BENCHMARK_TEMPLATE2_DEFINE_F(MyTemplate2, TestB, int, double)
60+
(benchmark::State &st) {
6161
for (auto _ : st) {
6262
}
6363
}

examples/google_benchmark_cmake/template_bench.hpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,27 @@
22
#define TEMPLATE_BENCH_HPP
33

44
#include <benchmark/benchmark.h>
5+
56
#include <cstring>
67
#include <string>
78

89
namespace test {
9-
template <class T> void BM_Template(benchmark::State &state) {
10+
template <class T>
11+
void BM_Template(benchmark::State &state) {
1012
std::vector<T> v;
1113
for (auto _ : state) {
1214
v.push_back(T());
1315
}
1416
}
1517
BENCHMARK_TEMPLATE(BM_Template, int);
1618
BENCHMARK_TEMPLATE(BM_Template, std::string);
17-
} // namespace test
19+
} // namespace test
1820

1921
//
2022
//
2123

22-
template <typename T> void BM_Template1(benchmark::State &state) {
24+
template <typename T>
25+
void BM_Template1(benchmark::State &state) {
2326
T val = T();
2427
for (auto _ : state) {
2528
benchmark::DoNotOptimize(val++);
@@ -30,7 +33,8 @@ BENCHMARK_TEMPLATE1(BM_Template1, int);
3033
//
3134
//
3235

33-
template <typename T, typename U> void BM_Template2(benchmark::State &state) {
36+
template <typename T, typename U>
37+
void BM_Template2(benchmark::State &state) {
3438
T t = T();
3539
U u = U();
3640
for (auto _ : state) {

0 commit comments

Comments
 (0)