11#include <benchmark/benchmark.h>
23#include <TRandomGen.h>
34static void BM_MergingTH1I(benchmark::State&
state)
37 const size_t bins = 62500;
39 TCollection* collection =
new TObjArray();
40 collection->SetOwner(
true);
41 TF1* uni =
new TF1(
"uni",
"1", 0, 1000000);
48 TH1I*
m =
new TH1I(
"merged",
"merged",
bins, 0, 1000000);
50 for (
size_t i = 0;
i <
bins;
i++) {
51 m->SetBinContent(
i, 1);
54 for (
auto _ :
state) {
59 auto start = std::chrono::high_resolution_clock::now();
60 m->Merge(collection,
"-NOCHECK");
61 auto end = std::chrono::high_resolution_clock::now();
63 auto elapsed_seconds = std::chrono::duration_cast<std::chrono::duration<double>>(
end -
start);
64 state.SetIterationTime(elapsed_seconds.count());
72static void BM_MergingTH2I(benchmark::State&
state)
77 TCollection* collection =
new TObjArray();
78 collection->SetOwner(
true);
79 TF2* uni =
new TF2(
"uni",
"1", 0, 1000000, 0, 1000000);
86 TH2I*
m =
new TH2I(
"merged",
"merged",
bins, 0, 1000000,
bins, 0, 1000000);
88 for (
size_t i = 0;
i <
bins;
i++) {
89 m->SetBinContent(
i, 1);
92 for (
auto _ :
state) {
97 auto start = std::chrono::high_resolution_clock::now();
98 m->Merge(collection,
"-NOCHECK");
99 auto end = std::chrono::high_resolution_clock::now();
101 auto elapsed_seconds = std::chrono::duration_cast<std::chrono::duration<double>>(
end -
start);
102 state.SetIterationTime(elapsed_seconds.count());
109static void BM_MergingTH3I(benchmark::State&
state)
114 TCollection* collection =
new TObjArray();
115 collection->SetOwner(
true);
116 TF3* uni =
new TF3(
"uni",
"1", 0, 1000000, 0, 1000000, 0, 1000000);
126 TH3I*
m =
new TH3I(
"merged",
"merged",
bins, 0, 1000000,
bins, 0, 1000000,
bins, 0, 1000000);
128 for (
size_t i = 0;
i <
bins;
i++) {
129 m->SetBinContent(
i, 1);
132 for (
auto _ :
state) {
137 auto start = std::chrono::high_resolution_clock::now();
138 m->Merge(collection,
"-NOCHECK");
139 auto end = std::chrono::high_resolution_clock::now();
141 auto elapsed_seconds = std::chrono::duration_cast<std::chrono::duration<double>>(
end -
start);
142 state.SetIterationTime(elapsed_seconds.count());
149static void BM_MergingTHnSparse(benchmark::State&
state)
153 const Double_t
min = 0.0;
154 const Double_t
max = 1000000.0;
155 const size_t dim = 10;
156 const Int_t
bins = 250;
162 gen.SetSeed(std::random_device()());
163 Double_t randomArray[dim];
164 auto*
m =
new THnSparseI(
"merged",
"merged", dim, binsDims, mins, maxs);
165 for (
auto _ :
state) {
167 TCollection* collection =
new TObjArray();
168 collection->SetOwner(
true);
171 auto*
h =
new THnSparseI((
"test" +
std::to_string(
i)).c_str(),
"test", dim, binsDims, mins, maxs);
173 gen.RndmArray(dim, randomArray);
174 for (
double&
r : randomArray) {
177 h->Fill(randomArray);
186 auto start = std::chrono::high_resolution_clock::now();
187 m->Merge(collection);
188 auto end = std::chrono::high_resolution_clock::now();
190 auto elapsed_seconds = std::chrono::duration_cast<std::chrono::duration<double>>(
end -
start);
191 state.SetIterationTime(elapsed_seconds.count());
198static void BM_MergingTTree(benchmark::State&
state)
210 auto createTree = [&](std::string
name) -> TTree* {
211 TTree*
tree =
new TTree();
213 tree->Branch(
"b1", &branch1,
"a/I:b/L:c/F:d/D");
214 tree->Branch(
"b2", &branch2);
219 gen.SetSeed(std::random_device()());
220 Double_t randomArray[5];
221 TTree* merged = createTree(
"merged");
223 for (
auto _ :
state) {
224 TCollection* collection =
new TObjArray();
225 collection->SetOwner(
true);
229 gen.RndmArray(5, randomArray);
230 branch1 = {
static_cast<Int_t
>(randomArray[0]),
static_cast<Long64_t
>(randomArray[1]),
static_cast<Float_t>(randomArray[2]), randomArray[3]};
231 branch2 = randomArray[4];
241 auto start = std::chrono::high_resolution_clock::now();
242 merged->Merge(collection,
"-NOCHECK");
243 auto end = std::chrono::high_resolution_clock::now();
245 auto elapsed_seconds = std::chrono::duration_cast<std::chrono::duration<double>>(
end -
start);
246 state.SetIterationTime(elapsed_seconds.count());
default_random_engine gen(dev())
std::vector< long > entries
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events d
bounded_vector< float > bins
BENCHMARK(BM_MergingTH1I) -> Arg(DIFF_OBJECTS) ->UseManualTime()
const size_t entriesInDiff
const size_t entriesInFull
const size_t collectionSize
Class for time synchronization of RawReader instances.
GLuint const GLchar * name
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
std::string to_string(gsl::span< T, Size > span)
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))