forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbenchmark_TableBuilder.cxx
More file actions
134 lines (113 loc) · 3.7 KB
/
benchmark_TableBuilder.cxx
File metadata and controls
134 lines (113 loc) · 3.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#include "Framework/TableBuilder.h"
#include <benchmark/benchmark.h>
using namespace o2::framework;
using namespace o2::soa;
static void BM_TableBuilderOverhead(benchmark::State& state)
{
using namespace o2::framework;
for (auto _ : state) {
TableBuilder builder;
[[maybe_unused]] auto rowWriter = builder.persist<float, float, float>({"x", "y", "z"});
auto table = builder.finalize();
}
}
BENCHMARK(BM_TableBuilderOverhead);
static void BM_TableBuilderScalar(benchmark::State& state)
{
using namespace o2::framework;
for (auto _ : state) {
TableBuilder builder;
auto rowWriter = builder.persist<float>({"x"});
for (auto i = 0; i < state.range(0); ++i) {
rowWriter(0, 0.f);
}
auto table = builder.finalize();
}
}
BENCHMARK(BM_TableBuilderScalar)->Arg(1 << 21);
BENCHMARK(BM_TableBuilderScalar)->Range(8, 8 << 16);
static void BM_TableBuilderScalarReserved(benchmark::State& state)
{
using namespace o2::framework;
for (auto _ : state) {
TableBuilder builder;
auto rowWriter = builder.persist<float>({"x"});
builder.reserve(o2::framework::pack<float>{}, state.range(0));
for (auto i = 0; i < state.range(0); ++i) {
rowWriter(0, 0.f);
}
auto table = builder.finalize();
}
}
BENCHMARK(BM_TableBuilderScalarReserved)->Arg(1 << 21);
BENCHMARK(BM_TableBuilderScalarReserved)->Range(8, 8 << 16);
static void BM_TableBuilderSimple(benchmark::State& state)
{
using namespace o2::framework;
for (auto _ : state) {
TableBuilder builder;
auto rowWriter = builder.persist<float, float, float>({"x", "y", "z"});
for (auto i = 0; i < state.range(0); ++i) {
rowWriter(0, 0.f, 0.f, 0.f);
}
auto table = builder.finalize();
}
}
BENCHMARK(BM_TableBuilderSimple)->Arg(1 << 20);
static void BM_TableBuilderSimple2(benchmark::State& state)
{
using namespace o2::framework;
for (auto _ : state) {
TableBuilder builder;
auto rowWriter = builder.persist<float, float, float>({"x", "y", "z"});
for (auto i = 0; i < state.range(0); ++i) {
rowWriter(0, 0.f, 0.f, 0.f);
}
auto table = builder.finalize();
}
}
BENCHMARK(BM_TableBuilderSimple2)->Range(8, 8 << 16);
namespace test
{
DECLARE_SOA_COLUMN(X, x, float);
DECLARE_SOA_COLUMN(Y, y, float);
DECLARE_SOA_COLUMN(Z, z, float);
} // namespace test
using TestVectors = o2::soa::InPlaceTable<"TST/0"_h, test::X, test::Y, test::Z>;
static void BM_TableBuilderSoA(benchmark::State& state)
{
using namespace o2::framework;
for (auto _ : state) {
TableBuilder builder;
auto rowWriter = builder.cursor<TestVectors>();
for (auto i = 0; i < state.range(0); ++i) {
rowWriter(0, 0.f, 0.f, 0.f);
}
auto table = builder.finalize();
}
}
BENCHMARK(BM_TableBuilderSoA)->Range(8, 8 << 16);
static void BM_TableBuilderComplex(benchmark::State& state)
{
using namespace o2::framework;
for (auto _ : state) {
TableBuilder builder;
auto rowWriter = builder.persist<int, float, std::string, bool>({"x", "y", "s", "b"});
for (auto i = 0; i < state.range(0); ++i) {
rowWriter(0, 0, 0., "foo", true);
}
auto table = builder.finalize();
}
}
BENCHMARK(BM_TableBuilderComplex)->Range(8, 8 << 16);
BENCHMARK_MAIN();