24 #include <type_traits> 26 long createNew(
int count) {
28 for (
int i = 0; i < count; ++i) {
35 long fillNew(
int count) {
37 for (
int i = 0; i < count; ++i)
38 hist.Fill({0.611, 0.611});
39 return hist.GetNDim();
42 long fillN(
int count) {
44 std::vector<std::array<double,2>>
v(count);
45 for (
int i = 0; i < count; ++i)
46 v[i] = {0.611, 0.611};
48 return hist.GetNDim();
51 long fillBufferedNew(
int count) {
53 Experimental::THistBufferedFill<Experimental::TH2D> filler(hist);
54 for (
int i = 0; i < count; ++i)
55 filler.Fill({0.611, 0.611});
56 return hist.GetNDim();
59 using timefunc_t = std::add_pointer_t<long(int)>;
61 void time1(timefunc_t
run,
int count,
const std::string&
name) {
62 using namespace std::chrono;
63 auto start = high_resolution_clock::now();
65 auto end = high_resolution_clock::now();
66 duration<double> time_span = duration_cast<duration<double>>(end - start);
68 std::cout << count <<
" * " << name <<
": " << time_span.count() <<
"seconds \n";
71 void time(timefunc_t r7,
int count,
const std::string& name) {
72 time1(r7, count, name +
" (ROOT7)");
76 time(createOld, createNew, 1000000,
"create 2D hists");
77 time(fillNew, 100000000,
"2D fills");
78 time(fillBufferedNew, 100000000,
"2D fills (buffered)");
void run(bool only_compile=false)
THist< 2, double, THistStatContent, THistStatUncertainty > TH2D