17#include <benchmark/benchmark.h>
18#include <boost/format.hpp>
28static void BM_HashedNameLookup(benchmark::State& state)
30 for (
auto _ :
state) {
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}}}});
40 auto x = registry.get<TH1>(
HIST(
"histo4"));
41 benchmark::DoNotOptimize(
x);
43 state.counters[
"Average lookup distance"] = ((double)registry.lookup / (
double)(
state.range(0)));
48static void BM_StandardNameLookup(benchmark::State& state)
50 for (
auto _ :
state) {
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));
60 auto x =
list.FindObject(
"histo4");
61 benchmark::DoNotOptimize(
x);
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);
const int nLookups
Number of lookups to perform.
BENCHMARK(BM_HashedNameLookup) -> Arg(4) ->Arg(8) ->Arg(16) ->Arg(64) ->Arg(128) ->Arg(256) ->Arg(512)
Defining PrimaryVertex explicitly as messageable.