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
14#include "TList.h"
15
16#include <benchmark/benchmark.h>
17#include <boost/format.hpp>
18
19using namespace o2::framework;
20using namespace arrow;
21
23const int nLookups = 100000;
24
26static void BM_HashedNameLookup(benchmark::State& state)
27{
28 for (auto _ : state) {
29 state.PauseTiming();
30 std::vector<HistogramSpec> histSpecs;
31 for (auto i = 0; i < state.range(0); ++i) {
32 histSpecs.push_back({fmt::format("histo{}", i + 1).c_str(), fmt::format("Histo {}", i + 1).c_str(), {HistType::kTH1F, {{100, 0, 1}}}});
33 }
34 HistogramRegistry registry{"registry", histSpecs};
35 state.ResumeTiming();
36
37 for (auto i = 0; i < nLookups; ++i) {
38 auto x = registry.get<TH1>(HIST("histo4"));
39 benchmark::DoNotOptimize(x);
40 }
41 state.counters["Average lookup distance"] = ((double)registry.lookup / (double)(state.range(0)));
42 }
43}
44
46static void BM_StandardNameLookup(benchmark::State& state)
47{
48 for (auto _ : state) {
49 state.PauseTiming();
50 TList list;
51 list.SetOwner();
52 for (auto i = 1; i <= state.range(0); ++i) {
53 list.Add(new TH1F((boost::format("histo%1%") % i).str().c_str(), (boost::format("Histo %1%") % i).str().c_str(), 100, 0, 1));
54 }
55 state.ResumeTiming();
56
57 for (auto i = 0; i < nLookups; ++i) {
58 auto x = list.FindObject("histo4");
59 benchmark::DoNotOptimize(x);
60 }
61 }
62}
63BENCHMARK(BM_HashedNameLookup)->Arg(4)->Arg(8)->Arg(16)->Arg(64)->Arg(128)->Arg(256)->Arg(512);
64BENCHMARK(BM_StandardNameLookup)->Arg(4)->Arg(8)->Arg(16)->Arg(64)->Arg(128)->Arg(256)->Arg(512);
65
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
bool list(IEventListener &reporter, Config const &config)
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
const std::string str