Skip to content

Commit cff0a3c

Browse files
sbstndbclaude
andcommitted
Fix formatting in comparison benchmarks
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 911413a commit cff0a3c

File tree

2 files changed

+20
-39
lines changed

2 files changed

+20
-39
lines changed

benchmark/comparison/blas1_comparison.cpp

Lines changed: 19 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include <cstddef>
77
#include <vector>
8+
89
#include <benchmark/benchmark.h>
910

1011
#include "xtensor/containers/xarray.hpp"
@@ -42,16 +43,16 @@ namespace xt::comparison
4243
return xt::xarray<double>::from_shape({size}) * val;
4344
}
4445

45-
// Macro for benchmark loop (reduces boilerplate)
46-
#define BENCHMARK_LOOP(state, container, ...) \
47-
for (auto _ : state) { \
48-
__VA_ARGS__; \
49-
benchmark::DoNotOptimize(container.data()); \
50-
}
46+
// Macro for benchmark loop (reduces boilerplate)
47+
#define BENCHMARK_LOOP(state, container, ...) \
48+
for (auto _ : state) \
49+
{ \
50+
__VA_ARGS__; \
51+
benchmark::DoNotOptimize(container.data()); \
52+
}
5153

52-
// Macro for registering benchmarks with standard sizes
53-
#define REGISTER_BENCHMARK(func) \
54-
BENCHMARK(func)->Range(min_size, max_size)->RangeMultiplier(multiplier)
54+
// Macro for registering benchmarks with standard sizes
55+
#define REGISTER_BENCHMARK(func) BENCHMARK(func)->Range(min_size, max_size)->RangeMultiplier(multiplier)
5556

5657
//========================================================================
5758
// Vector Addition: z = x + y
@@ -64,10 +65,7 @@ namespace xt::comparison
6465
std::vector<double> y(size, 2.0);
6566
std::vector<double> z(size);
6667

67-
BENCHMARK_LOOP(state, z,
68-
for (std::size_t i = 0; i < size; ++i)
69-
z[i] = x[i] + y[i];
70-
);
68+
BENCHMARK_LOOP(state, z, for (std::size_t i = 0; i < size; ++i) z[i] = x[i] + y[i];);
7169
}
7270

7371
static void add_vector_xarray(benchmark::State& state)
@@ -77,9 +75,7 @@ namespace xt::comparison
7775
auto y = make_xarray(size, 2.0);
7876
xt::xarray<double> z;
7977

80-
BENCHMARK_LOOP(state, z,
81-
z = x + y;
82-
);
78+
BENCHMARK_LOOP(state, z, z = x + y;);
8379
}
8480

8581
static void add_vector_xtensor(benchmark::State& state)
@@ -89,9 +85,7 @@ namespace xt::comparison
8985
auto y = make_xtensor(size, 2.0);
9086
xt::xtensor<double, 1> z;
9187

92-
BENCHMARK_LOOP(state, z,
93-
z = x + y;
94-
);
88+
BENCHMARK_LOOP(state, z, z = x + y;);
9589
}
9690

9791
static void add_vector_noalias(benchmark::State& state)
@@ -101,9 +95,7 @@ namespace xt::comparison
10195
auto y = make_xtensor(size, 2.0);
10296
auto z = make_xtensor_zeros(size);
10397

104-
BENCHMARK_LOOP(state, z,
105-
xt::noalias(z) = x + y;
106-
);
98+
BENCHMARK_LOOP(state, z, xt::noalias(z) = x + y;);
10799
}
108100

109101
//========================================================================
@@ -117,10 +109,7 @@ namespace xt::comparison
117109
std::vector<double> x(size, 1.0);
118110
std::vector<double> z(size);
119111

120-
BENCHMARK_LOOP(state, z,
121-
for (std::size_t i = 0; i < size; ++i)
122-
z[i] = x[i] + a;
123-
);
112+
BENCHMARK_LOOP(state, z, for (std::size_t i = 0; i < size; ++i) z[i] = x[i] + a;);
124113
}
125114

126115
static void add_scalar_xtensor(benchmark::State& state)
@@ -130,9 +119,7 @@ namespace xt::comparison
130119
auto x = make_xtensor(size, 1.0);
131120
xt::xtensor<double, 1> z;
132121

133-
BENCHMARK_LOOP(state, z,
134-
z = x + a;
135-
);
122+
BENCHMARK_LOOP(state, z, z = x + a;);
136123
}
137124

138125
static void add_scalar_noalias(benchmark::State& state)
@@ -142,9 +129,7 @@ namespace xt::comparison
142129
auto x = make_xtensor(size, 1.0);
143130
auto z = make_xtensor_zeros(size);
144131

145-
BENCHMARK_LOOP(state, z,
146-
xt::noalias(z) = x + a;
147-
);
132+
BENCHMARK_LOOP(state, z, xt::noalias(z) = x + a;);
148133
}
149134

150135
//========================================================================
@@ -158,10 +143,7 @@ namespace xt::comparison
158143
std::vector<double> x(size, 1.0);
159144
std::vector<double> y(size);
160145

161-
BENCHMARK_LOOP(state, y,
162-
for (std::size_t i = 0; i < size; ++i)
163-
y[i] = a * x[i];
164-
);
146+
BENCHMARK_LOOP(state, y, for (std::size_t i = 0; i < size; ++i) y[i] = a * x[i];);
165147
}
166148

167149
static void mul_scalar_xtensor(benchmark::State& state)
@@ -171,9 +153,7 @@ namespace xt::comparison
171153
auto x = make_xtensor(size, 1.0);
172154
xt::xtensor<double, 1> y;
173155

174-
BENCHMARK_LOOP(state, y,
175-
y = a * x;
176-
);
156+
BENCHMARK_LOOP(state, y, y = a * x;);
177157
}
178158

179159
//========================================================================

benchmark/comparison/comparison_main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
****************************************************************************/
44

55
#include <iostream>
6+
67
#include <benchmark/benchmark.h>
78

89
// Custom main for comparison benchmarks

0 commit comments

Comments
 (0)