Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
perf.cxx
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_exp
3///
4/// \macro_code
5///
6/// \date 2015-07-08
7/// \warning This is part of the experimental API, which might change in the future. Feedback is welcome!
8/// \author Axel Naumann <axel@cern.ch>
9
10/*************************************************************************
11 * Copyright (C) 1995-2015, Rene Brun and Fons Rademakers. *
12 * All rights reserved. *
13 * *
14 * For the licensing terms see $ROOTSYS/LICENSE. *
15 * For the list of contributors see $ROOTSYS/README/CREDITS. *
16 *************************************************************************/
17
18#include "ROOT/RHist.hxx"
19#include "ROOT/RFit.hxx"
21
22#include <chrono>
23#include <iostream>
24#include <type_traits>
25
26using namespace ROOT;
27
28long createNew(int count)
29{
30 long ret = 1;
31 for (int i = 0; i < count; ++i) {
32 Experimental::RH2D hist({{{100, 0., 1.}, {{0., 1., 2., 3., 10.}}}});
33 ret ^= (long)&hist;
34 }
35 return ret;
36}
37
38long fillNew(int count)
39{
40 Experimental::RH2D hist({{{100, 0., 1.}, {{0., 1., 2., 3., 10.}}}});
41 for (int i = 0; i < count; ++i)
42 hist.Fill({0.611, 0.611});
43 return hist.GetNDim();
44}
45
46long fillN(int count)
47{
48 Experimental::RH2D hist({{{100, 0., 1.}, {{0., 1., 2., 3., 10.}}}});
49 std::vector<Experimental::Hist::RCoordArray<2>> v(count);
50 for (int i = 0; i < count; ++i)
51 v[i] = {0.611, 0.611};
52 hist.FillN(v);
53 return hist.GetNDim();
54}
55
56long fillBufferedNew(int count)
57{
58 Experimental::RH2D hist({{{100, 0., 1.}, {{0., 1., 2., 3., 10.}}}});
60 for (int i = 0; i < count; ++i)
61 filler.Fill({0.611, 0.611});
62 return hist.GetNDim();
63}
64
65using timefunc_t = std::add_pointer_t<long(int)>;
66
67void time1(timefunc_t run, int count, const std::string &name)
68{
69 using namespace std::chrono;
70 auto start = high_resolution_clock::now();
71 run(count);
72 auto end = high_resolution_clock::now();
74
75 std::cout << count << " * " << name << ": " << time_span.count() << "seconds \n";
76}
77
78void time(timefunc_t r7, int count, const std::string &name)
79{
80 time1(r7, count, name + " (ROOT7)");
81}
82
83void perf()
84{
85 time(createNew, 1000000, "create 2D hists");
86 time(fillNew, 100000000, "2D fills");
87 time(fillBufferedNew, 100000000, "2D fills (buffered)");
88}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
char name[80]
Definition TGX11.cxx:110
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...