@@ -5,7 +5,7 @@ static constexpr char euclidean[] = "euclidean";
5
5
static constexpr char taxicab[] = " taxicab" ;
6
6
static constexpr char chebyshev[] = " chebyshev" ;
7
7
8
- template <typename T, const char * val>
8
+ template <typename T, const char * val>
9
9
struct Point3D {
10
10
T x;
11
11
T y;
@@ -19,9 +19,7 @@ struct Point3D {
19
19
}
20
20
T distance ()
21
21
{
22
- if constexpr (name == " x" ) {
23
- return x;
24
- }
22
+ if constexpr (name == " x" ) { return x; }
25
23
else if constexpr (name == " euclidean" ) {
26
24
return std::sqrt (x * x + y * y + z * z);
27
25
}
@@ -77,9 +75,8 @@ static void simdobjsort(benchmark::State &state)
77
75
std::vector<T> arr_bkp = arr;
78
76
// benchmark
79
77
for (auto _ : state) {
80
- x86simdsort::object_qsort (arr.data (), arr.size (), [](T p) {
81
- return p.distance ();
82
- });
78
+ x86simdsort::object_qsort (
79
+ arr.data (), arr.size (), [](T p) { return p.distance (); });
83
80
state.PauseTiming ();
84
81
if (!std::is_sorted (arr.begin (), arr.end (), less_than_key<T>())) {
85
82
std::cout << " sorting failed \n " ;
@@ -90,7 +87,7 @@ static void simdobjsort(benchmark::State &state)
90
87
}
91
88
92
89
#define BENCHMARK_OBJSORT (func, T, type, dist ) \
93
- BENCHMARK_TEMPLATE (func, T<type,dist>) \
90
+ BENCHMARK_TEMPLATE (func, T<type, dist>) \
94
91
->Arg(10e1 ) \
95
92
->Arg(10e2 ) \
96
93
->Arg(10e3 ) \
@@ -101,12 +98,12 @@ static void simdobjsort(benchmark::State &state)
101
98
#define BENCH_ALL (dtype ) \
102
99
BENCHMARK_OBJSORT (simdobjsort, Point3D, dtype, x) \
103
100
BENCHMARK_OBJSORT(scalarobjsort, Point3D, dtype, x) \
104
- BENCHMARK_OBJSORT(simdobjsort, Point3D, dtype, taxicab ) \
101
+ BENCHMARK_OBJSORT(simdobjsort, Point3D, dtype, taxicab) \
105
102
BENCHMARK_OBJSORT(scalarobjsort, Point3D, dtype, taxicab) \
106
103
BENCHMARK_OBJSORT(simdobjsort, Point3D, dtype, euclidean) \
107
104
BENCHMARK_OBJSORT(scalarobjsort, Point3D, dtype, euclidean) \
108
105
BENCHMARK_OBJSORT(simdobjsort, Point3D, dtype, chebyshev) \
109
- BENCHMARK_OBJSORT(scalarobjsort, Point3D, dtype, chebyshev) \
106
+ BENCHMARK_OBJSORT(scalarobjsort, Point3D, dtype, chebyshev)
110
107
111
108
BENCH_ALL(double )
112
109
BENCH_ALL(float )
0 commit comments