![Logo](../../ATLAS-Logo-Square-Blue-RGB.png) |
ATLAS Offline Software
|
Go to the documentation of this file.
22 #include "TProfile2D.h"
34 FILE*
file = fopen(
"/proc/self/status",
"r");
36 std::cerr <<
"ERROR: Could not open /proc/self/stat"<<std::endl;
41 while (fgets(
line, 128,
file) != NULL){
42 if (strncmp(
line,
"VmSize:", 7) == 0) {
43 std::stringstream
s(&(
line[7]));
80 const unsigned estimatedOverheadToDiscount = 0)
82 double t((clock()-
m_time_clock-estimatedOverheadToDiscount)*(1./
double(CLOCKS_PER_SEC))*1.0e6/
n);
83 std::cout<<
" Timed ["<<
text<<
"]: "<<
t<<
" microsecond"<<std::endl;
93 double end (
const std::string&
text,
const unsigned&
n,
const double&
extra=0.0)
96 std::cout<<
" Mem-usage ["<<
text<<
"]: "<<
m<<
" bytes"<<std::endl;
138 template <
class T>
T*
book(
const std::string&
n,
const std::string&
t,
unsigned nbins)
139 {
T*
h=
new T(
n.c_str(),
t.c_str(),
nbins,0.0,100.0);
158 template <>
TH2F*
book(
const std::string&
n,
const std::string&
t,
unsigned nbins)
160 template <>
TH2D*
book(
const std::string&
n,
const std::string&
t,
unsigned nbins)
162 template <>
TH2I*
book(
const std::string&
n,
const std::string&
t,
unsigned nbins)
179 template <
class T>
bool isROOT() {
return true; }
192 delete dynamic_cast<TH1*
>(
h);
201 const unsigned nbins,
205 std::vector<std::pair<std::string,T*> >
hists(
nhists);
208 std::ostringstream
s;
209 s <<
"some_hist_"<<
i;
210 hists.at(
i)=std::pair<std::string,T*>(
s.str(),0);
214 std::string
title(
"This is some title");
220 t1.end(histClassName<T>()+
" booking",
nhists);
221 double mem_booked =
m1.end(
"Booked size ["+histClassName<T>()+
"]",
hists.size());
226 const unsigned nrandfills = (nfills<0?-nfills:nfills);
229 const long clock1 = clock();
232 for (
unsigned i = 0;
i < nrandfills; ++
i)
233 fakeFillRandGen<T>(
rand);
234 const long loopandrandgenoverhead(clock()-clock1);
245 for (
unsigned i = 0;
i < nrandfills; ++
i)
247 t2.end(histClassName<T>()+
" average time of random fills (Fill(x,w))",
nhists*nrandfills,loopandrandgenoverhead);
250 for (
unsigned i = 0;
i < nrandfills; ++
i)
252 t2.end(histClassName<T>()+
" average time of random fills (Fill(x))",
nhists*nrandfills,loopandrandgenoverhead);
255 m2.end(
"Size after random fills ["+histClassName<T>()+
"]",
hists.size(),mem_booked);
264 long base_t0(clock());
266 it->second->GetName();
267 long base_t1(clock());
270 long actual_t0(clock());
273 long actual_t1(clock());
274 std::cout<<
"Conversion took "<<((actual_t1-actual_t0)-(base_t1-base_t0))/(
double(CLOCKS_PER_SEC)*
hists.size())*1.0
e3<<
" ms/hist"<<std::endl;
285 TH1F * hreport =
new TH1F(
"rootspy",
"",1,0,1);
286 hreport->Fill(
"rootspy_producereport",0.123456);
291 int usage (
const std::string& progname)
293 std::cout <<
"Usage:\n\n "
294 << progname <<
" [float|double|int|profile] [1d|2d] [root|lw|lwrb] [nbins] [nfills] [nhists]\n\n"
295 <<
" float|double|int|profile : type of histogram (e.g. TH1F vs. TH1D vs. TH1I vs. TProfile)\n\n"
296 <<
" 1d|2d : Dimension of histogram (e.g. TH1F vs. TH2F)\n\n"
297 <<
" 'root': benchmark cpu/vmem usage of booking & filling root hists\n"
298 <<
" 'lw': benchmark cpu/vmem usage of booking & filling lw hists + conversion lw->root\n\n"
299 <<
" 'lwrb': benchmark cpu/vmem usage of booking & filling lw hists using a root backend\n\n"
300 <<
" nbins : Number of histogram bins (in both dimensions for 2D hists)\n\n"
301 <<
" nfills : Number of fills per histogram (put <0 for fill(x,w) rather than fill(x))\n\n"
302 <<
" nhists : Number of histograms to use for test"
307 std::string progname=
argv[0];
309 return usage(progname);
313 if (nbins<1||nbins>USHRT_MAX-1||nhists<1||nhists>1000000)
314 return usage(progname);
317 if (histimpl==
"lwrb") {
320 std::cout<<
"Using ROOT backend for LW histograms."<<std::endl;
325 if (valtype==
"float"&&
dim==
"1d"&&histimpl==
"lw")
327 if (valtype==
"double"&&
dim==
"1d"&&histimpl==
"lw")
329 if (valtype==
"int"&&
dim==
"1d"&&histimpl==
"lw")
331 if (valtype==
"profile"&&
dim==
"1d"&&histimpl==
"lw")
333 if (valtype==
"float"&&
dim==
"1d"&&histimpl==
"root")
335 if (valtype==
"double"&&
dim==
"1d"&&histimpl==
"root")
337 if (valtype==
"int"&&
dim==
"1d"&&histimpl==
"root")
339 if (valtype==
"profile"&&
dim==
"1d"&&histimpl==
"root")
342 if (valtype==
"float"&&
dim==
"2d"&&histimpl==
"lw")
344 if (valtype==
"double"&&
dim==
"2d"&&histimpl==
"lw")
346 if (valtype==
"int"&&
dim==
"2d"&&histimpl==
"lw")
348 if (valtype==
"profile"&&
dim==
"2d"&&histimpl==
"lw")
350 if (valtype==
"float"&&
dim==
"2d"&&histimpl==
"root")
352 if (valtype==
"double"&&
dim==
"2d"&&histimpl==
"root")
354 if (valtype==
"int"&&
dim==
"2d"&&histimpl==
"root")
356 if (valtype==
"profile"&&
dim==
"2d"&&histimpl==
"root")
359 return usage(progname);
JetConstituentVector::iterator iterator
int performBenchmark(TRandom &rand, const unsigned nhists, const unsigned nbins, const int nfills)
void fakeFillRandGen< TH2D >(TRandom &rand)
void fakeFillRandGen< TH2F_LW >(TRandom &rand)
static TH1D_LW * create(const char *name, const char *title, unsigned nbinsx, const double &xlow, const double &xup)
std::string histClassName< TH2D_LW >()
std::string histClassName< TH2F_LW >()
int main(int argc, char **argv)
static TH1F_LW * create(const char *name, const char *title, unsigned nbinsx, const double &xlow, const double &xup)
std::string histClassName< TH2I >()
std::string histClassName< TProfile >()
void triggerConversion(T *)
std::vector< ALFA_RawDataCollection_p1 > t1
std::string histClassName()
static TH1I_LW * create(const char *name, const char *title, unsigned nbinsx, const double &xlow, const double &xup)
void fillXW(TRandom &rand, T *t)
std::string histClassName< TProfile2D_LW >()
double end(const std::string &text, const unsigned &n, const double &extra=0.0)
void fakeFillRandGen< TH2I_LW >(TRandom &rand)
std::string histClassName< TH1F >()
static TProfile2D_LW * create(const char *name, const char *title, unsigned nbinsx, const double &xlow, const double &xup, unsigned nbinsy, const double &ylow, const double &yup, const char *option=" ")
void fakeFillRandGen< TH2F >(TRandom &rand)
def TH2F(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=None, bins_par6=None, path='', **kwargs)
double end(const std::string &text, const unsigned &n, const unsigned estimatedOverheadToDiscount=0)
std::string histClassName< TH1I_LW >()
std::string histClassName< TH1I >()
double getRandX(TRandom &rand)
void fakeFillRandGen(TRandom &rand)
long long thisProcess_VirtualMemUsed_kB()
T * book(const std::string &n, const std::string &t, unsigned nbins)
static TProfile_LW * create(const char *name, const char *title, unsigned nbinsx, const double &xlow, const double &xup, const char *option=" ")
bool isROOT< TProfile2D_LW >()
static TH2I_LW * create(const char *name, const char *title, unsigned nbinsx, const double &xmin, const double &xmax, unsigned nbinsy, const double &ymin, const double &ymax)
static void setROOTBackend(bool)
void fillX(TRandom &rand, T *t)
std::string histClassName< TProfile2D >()
std::string histClassName< TProfile_LW >()
static void releaseAllHeldMemory()
std::string histClassName< TH2F >()
static TH2F_LW * create(const char *name, const char *title, unsigned nbinsx, const double &xmin, const double &xmax, unsigned nbinsy, const double &ymin, const double &ymax)
void fakeFillRandGen< TH2D_LW >(TRandom &rand)
int usage(const std::string &progname)
static void safeDelete(LWHist *)
static double poolWasteFraction()
std::vector< ALFA_RawDataContainer_p1 > t2
void fakeFillRandGen< TH2I >(TRandom &rand)
std::string histClassName< TH1D >()
std::string histClassName< TH1F_LW >()
std::string histClassName< TH2D >()
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
std::string histClassName< TH2I_LW >()
bool isROOT< TProfile_LW >()
std::string histClassName< TH1D_LW >()
static TH2D_LW * create(const char *name, const char *title, unsigned nbinsx, const double &xmin, const double &xmax, unsigned nbinsy, const double &ymin, const double &ymax)