Project
Loading...
Searching...
No Matches
benchmark_TableBuilder.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
13
14#include <benchmark/benchmark.h>
15
16using namespace o2::framework;
17using namespace o2::soa;
18
19static void BM_TableBuilderOverhead(benchmark::State& state)
20{
21 using namespace o2::framework;
22
23 for (auto _ : state) {
24 TableBuilder builder;
25 [[maybe_unused]] auto rowWriter = builder.persist<float, float, float>({"x", "y", "z"});
26 auto table = builder.finalize();
27 }
28}
29
30BENCHMARK(BM_TableBuilderOverhead);
31
32static void BM_TableBuilderScalar(benchmark::State& state)
33{
34 using namespace o2::framework;
35 for (auto _ : state) {
36 TableBuilder builder;
37 auto rowWriter = builder.persist<float>({"x"});
38 for (auto i = 0; i < state.range(0); ++i) {
39 rowWriter(0, 0.f);
40 }
41 auto table = builder.finalize();
42 }
43}
44
45BENCHMARK(BM_TableBuilderScalar)->Arg(1 << 21);
46BENCHMARK(BM_TableBuilderScalar)->Range(8, 8 << 16);
47
48static void BM_TableBuilderScalarReserved(benchmark::State& state)
49{
50 using namespace o2::framework;
51 for (auto _ : state) {
52 TableBuilder builder;
53 auto rowWriter = builder.persist<float>({"x"});
54 builder.reserve(o2::framework::pack<float>{}, state.range(0));
55 for (auto i = 0; i < state.range(0); ++i) {
56 rowWriter(0, 0.f);
57 }
58 auto table = builder.finalize();
59 }
60}
61
62BENCHMARK(BM_TableBuilderScalarReserved)->Arg(1 << 21);
63BENCHMARK(BM_TableBuilderScalarReserved)->Range(8, 8 << 16);
64
65static void BM_TableBuilderSimple(benchmark::State& state)
66{
67 using namespace o2::framework;
68 for (auto _ : state) {
69 TableBuilder builder;
70 auto rowWriter = builder.persist<float, float, float>({"x", "y", "z"});
71 for (auto i = 0; i < state.range(0); ++i) {
72 rowWriter(0, 0.f, 0.f, 0.f);
73 }
74 auto table = builder.finalize();
75 }
76}
77
78BENCHMARK(BM_TableBuilderSimple)->Arg(1 << 20);
79
80static void BM_TableBuilderSimple2(benchmark::State& state)
81{
82 using namespace o2::framework;
83 for (auto _ : state) {
84 TableBuilder builder;
85 auto rowWriter = builder.persist<float, float, float>({"x", "y", "z"});
86 for (auto i = 0; i < state.range(0); ++i) {
87 rowWriter(0, 0.f, 0.f, 0.f);
88 }
89 auto table = builder.finalize();
90 }
91}
92
93BENCHMARK(BM_TableBuilderSimple2)->Range(8, 8 << 16);
94
95namespace test
96{
100} // namespace test
101
102using TestVectors = o2::soa::InPlaceTable<"TST/0"_h, test::X, test::Y, test::Z>;
103
104static void BM_TableBuilderSoA(benchmark::State& state)
105{
106 using namespace o2::framework;
107 for (auto _ : state) {
108 TableBuilder builder;
109 auto rowWriter = builder.cursor<TestVectors>();
110 for (auto i = 0; i < state.range(0); ++i) {
111 rowWriter(0, 0.f, 0.f, 0.f);
112 }
113 auto table = builder.finalize();
114 }
115}
116
117BENCHMARK(BM_TableBuilderSoA)->Range(8, 8 << 16);
118
119static void BM_TableBuilderComplex(benchmark::State& state)
120{
121 using namespace o2::framework;
122 for (auto _ : state) {
123 TableBuilder builder;
124 auto rowWriter = builder.persist<int, float, std::string, bool>({"x", "y", "s", "b"});
125 for (auto i = 0; i < state.range(0); ++i) {
126 rowWriter(0, 0, 0., "foo", true);
127 }
128 auto table = builder.finalize();
129 }
130}
131
132BENCHMARK(BM_TableBuilderComplex)->Range(8, 8 << 16);
133
#define DECLARE_SOA_COLUMN(_Name_, _Getter_, _Type_)
Definition ASoA.h:2322
benchmark::State & state
int32_t i
BENCHMARK_MAIN()
BENCHMARK(BM_TableBuilderOverhead)
auto reserve(o2::framework::pack< ARGS... > &&, int s)
auto persist(std::array< char const *, sizeof...(ARGS)+1 > const &columnNames)
std::shared_ptr< arrow::Table > finalize()
GLint GLenum GLint x
Definition glcorearb.h:403
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
FIXME: do not use data model tables.