26 #include <type_traits> 28 long createNewII(
int count) {
30 for (
int i = 0; i < count; ++i) {
38 static const int nBinsX = 4; \ 39 double x[nBinsX] = {0., 0.1, 0.3, 1.}; \ 40 static const int nBinsY = 5; \ 41 double y[nBinsY] = {0., 1., 2., 3., 10.} 44 TH2D hist("a", "a hist", nBinsX - 1, x, nBinsY - 1, y) 51 long createOldII(
int count) {
54 for (
int i = 0; i < count; ++i) {
61 long fillNewII(
int count) {
63 for (
int i = 0; i < count; ++i)
64 hist.Fill({0.611, 0.611});
65 return hist.GetNDim();
68 long fillOldII(
int count) {
70 for (
int i = 0; i < count; ++i)
71 hist.Fill(0.611, 0.611);
72 return (
long)hist.GetEntries();
75 long fillNII(
int count) {
77 std::vector<std::array<double,2>>
v(count);
78 for (
int i = 0; i < count; ++i)
79 v[i] = {0.611, 0.611};
81 return hist.GetNDim();
84 long fillBufferedOldII(
int count) {
87 for (
int i = 0; i < count; ++i)
88 hist.Fill(0.611, 0.611);
89 return (
long)hist.GetEntries();
92 long fillBufferedNewII(
int count) {
94 Experimental::THistBufferedFill<Experimental::TH2D> filler(hist);
95 for (
int i = 0; i < count; ++i)
96 filler.Fill({0.611, 0.611});
97 return hist.GetNDim();
104 long createNewEE(
int count) {
106 for (
int i = 0; i < count; ++i) {
113 long createOldEE(
int count) {
115 for (
int i = 0; i < count; ++i) {
116 TH2D hist(
"a",
"a hist", 100, 0., 1., 5, 0., 10.);
122 long fillNewEE(
int count) {
124 for (
int i = 0; i < count; ++i)
125 hist.Fill({0.611, 0.611});
126 return hist.GetNDim();
129 long fillOldEE(
int count) {
130 TH2D hist(
"a",
"a hist", 100, 0., 1., 5, 0., 10.);
131 for (
int i = 0; i < count; ++i)
132 hist.Fill(0.611, 0.611);
133 return (
long)hist.GetEntries();
136 long fillNEE(
int count) {
138 std::vector<std::array<double,2>>
v(count);
139 for (
int i = 0; i < count; ++i)
140 v[i] = {0.611, 0.611};
142 return hist.GetNDim();
145 long fillBufferedOldEE(
int count) {
146 TH2D hist(
"a",
"a hist", 100, 0., 1., 5, 0., 10.);
148 for (
int i = 0; i < count; ++i)
149 hist.Fill(0.611, 0.611);
150 return (
long)hist.GetEntries();
153 long fillBufferedNewEE(
int count) {
155 Experimental::THistBufferedFill<Experimental::TH2D> filler(hist);
156 for (
int i = 0; i < count; ++i)
157 filler.Fill({0.611, 0.611});
158 return hist.GetNDim();
162 using timefunc_t = std::add_pointer_t<long(int)>;
164 void time1(timefunc_t
run,
int count,
const std::string&
name) {
165 using namespace std::chrono;
166 auto start = high_resolution_clock::now();
168 auto end = high_resolution_clock::now();
169 duration<double> time_span = duration_cast<duration<double>>(end - start);
171 std::cout << count <<
" * " << name <<
": " << time_span.count() <<
"seconds \n";
174 void time(timefunc_t r6, timefunc_t r7,
int count,
const std::string& name) {
175 time1(r6, count, name +
" (ROOT6)");
176 time1(r7, count, name +
" (ROOT7)");
180 int factor = 1000000;
182 time(createOldII, createNewII, factor,
"create 2D hists [II]");
183 time(createOldEE, createNewEE, factor,
"create 2D hists [EE]");
184 time(fillOldII, fillNewII, 100 * factor,
"2D fills [II]");
185 time(fillOldEE, fillNewEE, 100 * factor,
"2D fills [EE]");
186 time(fillBufferedOldII, fillBufferedNewII, 100 * factor,
"2D fills (buffered) [II]");
187 time(fillBufferedOldEE, fillBufferedNewEE, 100 * factor,
"2D fills (buffered) [EE]");
void run(bool only_compile=false)
static Int_t GetDefaultBufferSize()
Static function return the default buffer size for automatic histograms the parameter fgBufferSize ma...
THist< 2, double, THistStatContent, THistStatUncertainty > TH2D
tomato 2-D histogram with a double per channel (see TH1 documentation)}