27 #include <type_traits>
29 using namespace ROOT::Experimental;
31 long createNewII(
int count)
34 for (
int i = 0; i < count; ++i) {
35 RH2D hist({{{{0., 0.1, 0.3, 1.}}, {{0., 1., 2., 3., 10.}}}});
42 static const int nBinsX = 4; \
43 double x[nBinsX] = {0., 0.1, 0.3, 1.}; \
44 static const int nBinsY = 5; \
45 double y[nBinsY] = {0., 1., 2., 3., 10.}
47 #define DECLOLD TH2D hist("a", "a hist", nBinsX - 1, x, nBinsY - 1, y)
53 long createOldII(
int count)
57 for (
int i = 0; i < count; ++i) {
64 long fillNewII(
int count)
66 RH2D hist({{{{0., 0.1, 0.3, 1.}}, {{0., 1., 2., 3., 10.}}}});
67 for (
int i = 0; i < count; ++i)
68 hist.Fill({0.611, 0.611});
69 return hist.GetNDim();
72 long fillOldII(
int count)
75 for (
int i = 0; i < count; ++i)
76 hist.Fill(0.611, 0.611);
77 return (
long)hist.GetEntries();
80 long fillNII(
int count)
82 RH2D hist({{{{0., 0.1, 0.3, 1.}}, {{0., 1., 2., 3., 10.}}}});
83 std::vector<Hist::RCoordArray<2>> v(count);
84 for (
int i = 0; i < count; ++i)
85 v[i] = {0.611, 0.611};
87 return hist.GetNDim();
90 long fillBufferedOldII(
int count)
93 hist.SetBuffer(TH1::GetDefaultBufferSize());
94 for (
int i = 0; i < count; ++i)
95 hist.Fill(0.611, 0.611);
96 return (
long)hist.GetEntries();
99 long fillBufferedNewII(
int count)
101 RH2D hist({{{{0., 0.1, 0.3, 1.}}, {{0., 1., 2., 3., 10.}}}});
102 RHistBufferedFill<RH2D> filler(hist);
103 for (
int i = 0; i < count; ++i)
104 filler.Fill({0.611, 0.611});
105 return hist.GetNDim();
110 long createNewEE(
int count)
113 for (
int i = 0; i < count; ++i) {
114 RH2D hist({{{100, 0., 1.}, {5, 0., 10.}}});
120 long createOldEE(
int count)
123 for (
int i = 0; i < count; ++i) {
124 TH2D hist(
"a",
"a hist", 100, 0., 1., 5, 0., 10.);
130 long fillNewEE(
int count)
132 RH2D hist({{{100, 0., 1.}, {5, 0., 10.}}});
133 for (
int i = 0; i < count; ++i)
134 hist.Fill({0.611, 0.611});
135 return hist.GetNDim();
138 long fillOldEE(
int count)
140 TH2D hist(
"a",
"a hist", 100, 0., 1., 5, 0., 10.);
141 for (
int i = 0; i < count; ++i)
142 hist.Fill(0.611, 0.611);
143 return (
long)hist.GetEntries();
146 long fillNEE(
int count)
148 RH2D hist({{{100, 0., 1.}, {5, 0., 10.}}});
149 std::vector<Hist::RCoordArray<2>> v(count);
150 for (
int i = 0; i < count; ++i)
151 v[i] = {0.611, 0.611};
153 return hist.GetNDim();
156 long fillBufferedOldEE(
int count)
158 TH2D hist(
"a",
"a hist", 100, 0., 1., 5, 0., 10.);
159 hist.SetBuffer(TH1::GetDefaultBufferSize());
160 for (
int i = 0; i < count; ++i)
161 hist.Fill(0.611, 0.611);
162 return (
long)hist.GetEntries();
165 long fillBufferedNewEE(
int count)
167 RH2D hist({{{100, 0., 1.}, {5, 0., 10.}}});
168 RHistBufferedFill<RH2D> filler(hist);
169 for (
int i = 0; i < count; ++i)
170 filler.Fill({0.611, 0.611});
171 return hist.GetNDim();
174 using timefunc_t = std::add_pointer_t<long(int)>;
176 void time1(timefunc_t run,
int count,
const std::string &name)
178 using namespace std::chrono;
179 auto start = high_resolution_clock::now();
181 auto end = high_resolution_clock::now();
182 duration<double> time_span = duration_cast<duration<double>>(end - start);
184 std::cout << count <<
" * " << name <<
": " << time_span.count() <<
"seconds \n";
187 void time(timefunc_t r6, timefunc_t r7,
int count,
const std::string &name)
189 time1(r6, count, name +
" (ROOT6)");
190 time1(r7, count, name +
" (ROOT7)");
195 int factor = 1000000;
197 time(createOldII, createNewII, factor,
"create 2D hists [II]");
198 time(createOldEE, createNewEE, factor,
"create 2D hists [EE]");
199 time(fillOldII, fillNewII, 100 * factor,
"2D fills [II]");
200 time(fillOldEE, fillNewEE, 100 * factor,
"2D fills [EE]");
201 time(fillBufferedOldII, fillBufferedNewII, 100 * factor,
"2D fills (buffered) [II]");
202 time(fillBufferedOldEE, fillBufferedNewEE, 100 * factor,
"2D fills (buffered) [EE]");