11#include <benchmark/benchmark.h>
19static void BM_dynamic_cast(benchmark::State&
state)
21 TCollection* collection =
new TList();
22 collection->SetOwner(
true);
23 TH1I*
h =
new TH1I(
"histo",
"histo", 1000, 0, 1000000);
26 TObject* collectionObj = collection;
29 for (
auto _ :
state) {
30 if (
auto*
list =
dynamic_cast<TList*
>(collectionObj)) {
31 entries +=
list->GetEntries();
39static void BM_InheritsFrom(benchmark::State&
state)
41 TCollection* collection =
new TList();
42 collection->SetOwner(
true);
43 TH1I*
h =
new TH1I(
"histo",
"histo", 1000, 0, 1000000);
46 TObject* collectionObj = collection;
48 for (
auto _ :
state) {
49 if (collectionObj->InheritsFrom(
"TCollection")) {
50 entries +=
reinterpret_cast<TList*
>(collectionObj)->GetEntries();
58static void BM_MergeCollectionOnHeap(benchmark::State&
state)
60 TCollection* collection =
new TObjArray();
61 collection->SetOwner(
true);
62 TF1* uni =
new TF1(
"uni",
"1", 0, 1000000);
63 TH1I*
h =
new TH1I(
"test",
"test", 100, 0, 1000000);
64 TH1I*
m =
new TH1I(
"merged",
"merged", 100, 0, 1000000);
65 h->FillRandom(
"uni", 50000);
68 for (
auto _ :
state) {
77static void BM_MergeCollectionOnStack(benchmark::State&
state)
80 collection.SetOwner(
true);
81 TF1* uni =
new TF1(
"uni",
"1", 0, 1000000);
82 TH1I*
h =
new TH1I(
"test",
"test", 100, 0, 1000000);
83 TH1I*
m =
new TH1I(
"merged",
"merged", 100, 0, 1000000);
84 h->FillRandom(
"uni", 50000);
87 for (
auto _ :
state) {
88 m->Merge(&collection);
95static void BM_MergeWithoutNoCheck(benchmark::State&
state)
100 TCollection* collection =
new TObjArray();
101 collection->SetOwner(
true);
102 TF1* uni =
new TF1(
"uni",
"1", 0, 1000000);
105 h->FillRandom(
"uni", 50000);
109 TH1I*
m =
new TH1I(
"merged",
"merged",
bins, 0, 1000000);
111 for (
auto _ :
state) {
112 m->Merge(collection);
120static void BM_MergeWithNoCheck(benchmark::State&
state)
125 TCollection* collection =
new TObjArray();
126 collection->SetOwner(
true);
127 TF1* uni =
new TF1(
"uni",
"1", 0, 1000000);
130 h->FillRandom(
"uni", 50000);
134 TH1I*
m =
new TH1I(
"merged",
"merged",
bins, 0, 1000000);
136 for (
auto _ :
state) {
137 m->Merge(collection);
145static void BM_ClassComparisonCString(benchmark::State&
state)
147 bool thisTriesToAvoidOptimization = std::rand();
149 if (thisTriesToAvoidOptimization) {
150 h =
new TH1I(
"histo",
"histo", 1000, 0, 1000000);
152 h =
new TH1F(
"histo",
"histo", 1000, 0, 1000000);
157 for (
auto _ :
state) {
158 const char* className =
h->ClassName();
159 if (strncmp(className,
"TH1", 3) == 0) {
168static void BM_ClassComparisonInterface(benchmark::State&
state)
170 bool thisTriesToAvoidOptimization = std::rand();
172 if (thisTriesToAvoidOptimization) {
173 h =
new TH1I(
"histo",
"histo", 1000, 0, 1000000);
175 h =
new TH1F(
"histo",
"histo", 1000, 0, 1000000);
181 for (
auto _ :
state) {
182 if (
h->InheritsFrom(TH1::Class())) {
const size_t collectionSize
BENCHMARK(BM_dynamic_cast)
Class for time synchronization of RawReader instances.
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
std::string to_string(gsl::span< T, Size > span)