Project
Loading...
Searching...
No Matches
benchmark_GandivaExpressions.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
14
16#include "Framework/Logger.h"
17
18#include <benchmark/benchmark.h>
19#include <random>
20
21using namespace o2::framework;
22using namespace arrow;
23using namespace o2::soa;
24
25namespace test
26{
27DECLARE_SOA_COLUMN(X, x, float, "x");
28DECLARE_SOA_COLUMN(Y, y, float, "y");
29DECLARE_SOA_COLUMN(Z, z, float, "z");
30DECLARE_SOA_COLUMN(cD, cd, float, "cd");
31DECLARE_SOA_DYNAMIC_COLUMN(D, d, [](float x, float y, float z) { return std::sqrt(x * x + y * y + z * z); });
32} // namespace test
33
36
37const static size_t maxrows = 100;
38
39static std::default_random_engine e(1234567890);
40static std::normal_distribution<float> G;
41
42auto createTable = [](size_t nrows) {
43 static TableBuilder builder;
44 auto static rowWriter = builder.persist<float, float, float>({"x", "y", "z"});
45
46 for (auto i = 0u; i < nrows; ++i) {
47 rowWriter(0, G(e), G(e), G(e));
48 }
49 auto table = builder.finalize();
50
51 return TT{table};
52};
53
54static void BM_DirectCalculation(benchmark::State& state)
55{
56 state.PauseTiming();
57 auto tt = createTable(state.range(0));
58 state.ResumeTiming();
59 benchmark::DoNotOptimize(tt);
60}
61
62static void BM_GandivaExpression(benchmark::State& state)
63{
64 state.PauseTiming();
65 auto tt = createTable(state.range(0));
66 state.ResumeTiming();
67 benchmark::DoNotOptimize(tt);
68}
69
70BENCHMARK(BM_DirectCalculation)->Arg(maxrows);
71BENCHMARK(BM_GandivaExpression)->Arg(maxrows);
72
#define DECLARE_SOA_DYNAMIC_COLUMN(_Name_, _Getter_,...)
Definition ASoA.h:2967
#define DECLARE_SOA_COLUMN(_Name_, _Getter_, _Type_)
Definition ASoA.h:2314
benchmark::State & state
int32_t i
BENCHMARK_MAIN()
BENCHMARK(BM_DirectCalculation) -> Arg(maxrows)
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.