Project
Loading...
Searching...
No Matches
benchmark_HistogramRegistry.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#include "Framework/Logger.h"
14
15#include "TList.h"
16
17#include <benchmark/benchmark.h>
18#include <boost/format.hpp>
19
20using namespace o2::framework;
21using namespace arrow;
22using namespace o2::soa;
23
25const int nLookups = 100000;
26
28static void BM_HashedNameLookup(benchmark::State& state)
29{
30 for (auto _ : state) {
31 state.PauseTiming();
32 std::vector<HistogramSpec> histSpecs;
33 for (auto i = 0; i < state.range(0); ++i) {
34 histSpecs.push_back({fmt::format("histo{}", i + 1).c_str(), fmt::format("Histo {}", i + 1).c_str(), {HistType::kTH1F, {{100, 0, 1}}}});
35 }
36 HistogramRegistry registry{"registry", histSpecs};
37 state.ResumeTiming();
38
39 for (auto i = 0; i < nLookups; ++i) {
40 auto x = registry.get<TH1>(HIST("histo4"));
41 benchmark::DoNotOptimize(x);
42 }
43 state.counters["Average lookup distance"] = ((double)registry.lookup / (double)(state.range(0)));
44 }
45}
46
48static void BM_StandardNameLookup(benchmark::State& state)
49{
50 for (auto _ : state) {
51 state.PauseTiming();
52 TList list;
53 list.SetOwner();
54 for (auto i = 1; i <= state.range(0); ++i) {
55 list.Add(new TH1F((boost::format("histo%1%") % i).str().c_str(), (boost::format("Histo %1%") % i).str().c_str(), 100, 0, 1));
56 }
57 state.ResumeTiming();
58
59 for (auto i = 0; i < nLookups; ++i) {
60 auto x = list.FindObject("histo4");
61 benchmark::DoNotOptimize(x);
62 }
63 }
64}
65BENCHMARK(BM_HashedNameLookup)->Arg(4)->Arg(8)->Arg(16)->Arg(64)->Arg(128)->Arg(256)->Arg(512);
66BENCHMARK(BM_StandardNameLookup)->Arg(4)->Arg(8)->Arg(16)->Arg(64)->Arg(128)->Arg(256)->Arg(512);
67
benchmark::State & state
int32_t i
#define HIST(name)
const int nLookups
Number of lookups to perform.
BENCHMARK_MAIN()
BENCHMARK(BM_HashedNameLookup) -> Arg(4) ->Arg(8) ->Arg(16) ->Arg(64) ->Arg(128) ->Arg(256) ->Arg(512)
GLint GLenum GLint x
Definition glcorearb.h:403
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
Definition list.h:40
const std::string str