140 Warning(
"TTreePerfStats",
"Results obtained with ImplicitMT enabled are not reliable.");
145 T->SetPerfStats(
this);
146 fNleaves= T->GetListOfLeaves()->GetEntries();
147 fFile = T->GetCurrentFile();
172 fCompress = (T->GetTotBytes()+0.00001)/T->GetZipBytes();
174 bool isUNIX = strcmp(
gSystem->GetName(),
"Unix") == 0;
222 const Int_t kMaxDiff = 7;
227 if (py < puymax)
return 9999;
230 if (distance <kMaxDiff) {
if (px > puxmin && py < puymin)
gPad->SetSelected(
fGraphIO);
return distance;}
232 distance =
fGraphTime->DistancetoPrimitive(px,py);
233 if (distance <kMaxDiff) {
if (px > puxmin && py < puymin)
gPad->SetSelected(
fGraphTime);
return distance;}
235 distance =
fPave->DistancetoPrimitive(px,py);
236 if (distance <kMaxDiff) {
gPad->SetSelected(
fPave);
return distance;}
243 if (px > puxmax-300)
return 2;
258 if (strlen(option)==0) opt =
"al";
261 if (!
gPad->IsEditable())
gROOT->MakeDefCanvas();
266 gROOT->MakeDefCanvas();
269 gPad->SetLeftMargin(0.35);
291 if (file == this->
fFile) {
295 fGraphIO->SetPoint(np,entry,1
e-6*offset);
296 fGraphIO->SetPointError(np,0.001,1
e-9*len);
317 if (tree == this->
fTree || tree == this->
fTree->GetTree()){
339 if (
fTree->IsA()->InheritsFrom(
"TChain"))
348 if (!npoints)
return;
353 for (
Int_t i=1;i<npoints;i++) {
367 for (
int i = 0; i < branches->
GetEntries(); ++i) {
392 for (
Int_t i = 0; i < branches->GetEntries(); ++i) {
393 if (br == branches->UncheckedAt(i)) {
402 index = iter->second;
417 if (brvec.size() <= basketNumber)
418 brvec.resize(basketNumber + 1);
420 return brvec[basketNumber];
444 if ((info.fLoaded + info.fLoadedMiss) > 1) {
446 result.emplace_back(BasketList_t::value_type((
TBranch*)branches->At(i), std::vector<size_t>(1)));
449 auto &ref( result.back() );
450 ref.second.push_back(j);
464 if (!npoints)
return;
467 if (iomax >= 1e9) toffset = 1.2;
468 fGraphIO->GetXaxis()->SetTitle(
"Tree entry number");
469 fGraphIO->GetYaxis()->SetTitle(
"file position (MBytes) ");
470 fGraphIO->GetYaxis()->SetTitleOffset(toffset);
471 fGraphIO->GetXaxis()->SetLabelSize(0.03);
472 fGraphIO->GetYaxis()->SetLabelSize(0.03);
477 bool unzip = opts.
Contains(
"unzip");
509 fPave->SetTextAlign(12);
517 fPave->AddText(
Form(
"Readextra = %5.2f per cent",extra));
547 bool unzip = opts.
Contains(
"unzip");
548 bool basket = opts.
Contains(
"basket");
560 printf(
"Readextra = %5.2f per cent\n",extra);
561 printf(
"Real Time = %7.3f seconds\n",
fRealTime);
562 printf(
"CPU Time = %7.3f seconds\n",
fCpuTime);
563 printf(
"Disk Time = %7.3f seconds\n",
fDiskTime);
566 printf(
"UnzipTime = %7.3f seconds\n",
fUnzipTime);
589 bool all = opts.
Contains(
"allbasketinfo");
601 const char *branchname = branches->At(i)->GetName();
603 printf(
" br=%zu %s read not cached: ", i, branchname);
613 printf(
" br=%zu %s cached more than once: ", i, branchname);
616 if ((info.fLoaded + info.fLoadedMiss) > 1)
617 printf(
"%zu[%d,%d] ", j, info.fLoaded, info.fLoadedMiss);
621 printf(
" br=%zu %s cached but not used: ", i, branchname);
624 if ((info.fLoaded + info.fLoadedMiss) && !info.fUsed) {
625 if (info.fLoadedMiss)
626 printf(
"%zu[%d,%d] ", j, info.fLoaded, info.fLoadedMiss);
634 printf(
" br=%zu %s: ", i, branchname);
637 printf(
"%zu[%d,%d,%d,%d] ", j, info.fUsed, info.fLoaded, info.fLoadedMiss, info.fMissed);
643 printf(
" br=%d %s: no basket information\n", i, branches->At(i)->GetName());
654 ps->TObject::SaveAs(filename);
665 out <<
" perfstats->SetTreeCacheSize(" <<
fTreeCacheSize <<
");\n";
666 out <<
" perfstats->SetNleaves(" <<
fNleaves <<
");\n";
667 out <<
" perfstats->SetReadCalls(" <<
fReadCalls <<
");\n";
668 out <<
" perfstats->SetReadaheadSize(" <<
fReadaheadSize <<
");\n";
669 out <<
" perfstats->SetBytesRead(" <<
fBytesRead <<
");\n";
671 out <<
" perfstats->SetRealNorm(" <<
fRealNorm <<
");\n";
672 out <<
" perfstats->SetRealTime(" <<
fRealTime <<
");\n";
673 out <<
" perfstats->SetCpuTime(" <<
fCpuTime <<
");\n";
674 out <<
" perfstats->SetDiskTime(" <<
fDiskTime <<
");\n";
675 out <<
" perfstats->SetUnzipTime(" <<
fUnzipTime <<
");\n";
676 out <<
" perfstats->SetCompress(" <<
fCompress <<
");\n";
678 fGraphIO->SavePrimitive(out,
"nodraw");
679 out <<
" perfstats->SetGraphIO(gre);\n";
682 out <<
" perfstats->SetGraphTime(gre);\n";
int Int_t
Signed integer 4 bytes (int).
double Double_t
Double 8 bytes.
long long Long64_t
Portable signed long integer 8 bytes.
const char Option_t
Option string (const char).
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
A TTree is a list of TBranches.
Using a TBrowser one can browse all ROOT objects.
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
const char * AsString() const
Return the date & time as a string (ctime() format).
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
static Int_t GetReadaheadSize()
Static function returning the readahead buffer size.
Long64_t GetRelOffset() const
TFileCacheRead * GetCacheRead(const TObject *tree=nullptr) const
Return a pointer to the current read cache.
Int_t GetEntries() const override
Return the number of objects in array (i.e.
TObject * UncheckedAt(Int_t i) const
Bool_t TestBit(UInt_t f) const
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
static void SavePrimitiveDraw(std::ostream &out, const char *variable_name, Option_t *option=nullptr)
Save invocation of primitive Draw() method Skipped if option contains "nodraw" string.
TObject()
TObject constructor.
static void SavePrimitiveConstructor(std::ostream &out, TClass *cl, const char *variable_name, const char *constructor_agrs="", Bool_t empty_line=kTRUE)
Save object constructor in the output stream "out".
@ kCanDelete
if object in a list can be deleted
void ToLower()
Change string to lower-case.
TString & ReplaceSpecialCppChars()
Find special characters which are typically used in printf() calls and replace them by appropriate es...
const char * Data() const
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
void Paint(Option_t *option="") override
This method must be overridden if a class wants to paint itself.
The TTimeStamp encapsulates seconds and ns since EPOCH.
A cache to speed-up the reading of ROOT datasets.
const TObjArray * GetCachedBranches() const
TGraphErrors * fGraphIO
Pointer to the graph with IO data.
Long64_t fUnzipInputSize
Compressed bytes seen by the decompressor.
TString fName
Name of this TTreePerfStats.
Int_t fNleaves
Number of leaves in the tree.
void Browse(TBrowser *b) override
Browse.
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Return distance to one of the objects in the TTreePerfStats.
Double_t fRealNorm
Real time scale factor for fGraphTime.
BasketInfo & GetBasketInfo(TBranch *b, size_t basketNumber)
Return the BasketInfo corresponding to the given branch and basket.
std::vector< std::vector< BasketInfo > > fBasketsInfo
Long64_t fUnzipObjSize
Uncompressed bytes produced by the decompressor.
TStopwatch * fWatch
TStopwatch pointer.
TTree * fTree
! Pointer to the Tree being monitored
TString fHostInfo
Name of the host system, ROOT version and date.
void Print(Option_t *option="") const override
Print the TTree I/O perf stats.
Int_t fReadCalls
Number of read calls.
Long64_t fBytesRead
Number of bytes read.
void UpdateBranchIndices(TObjArray *branchNames) override
Update the fBranchIndexCache collection to match the current TTree given the ordered list of branch n...
BasketList_t GetDuplicateBasketCache() const
Return the collection of baskets which have been read by the TTreeCache more than once.
Double_t fCpuTime
Cpu time.
virtual void Finish()
When the run is finished this function must be called to save the current parameters in the file and ...
const char * GetName() const override
Returns name of object.
void Paint(Option_t *chopt="") override
Draw the TTree I/O perf graph.
std::vector< std::pair< TBranch *, std::vector< size_t > > > BasketList_t
void SaveAs(const char *filename="", Option_t *option="") const override
Save this object to filename.
void FileReadEvent(TFile *file, Int_t len, Double_t start) override
Record TTree file read event.
Double_t fCompress
Tree compression factor.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
void PrintBasketInfo(Option_t *option="") const override
Print the TTree basket information.
void Draw(Option_t *option="") override
Draw the TTree I/O perf graph.
TFile * fFile
! Pointer to the file containing the Tree
const char * GetHostInfo() const
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Return distance to one of the objects in the TTreePerfStats.
Double_t fRealTime
Real time.
Int_t fReadaheadSize
Read-ahead cache size.
std::unordered_map< TBranch *, size_t > fBranchIndexCache
~TTreePerfStats() override
Destructor.
Double_t fDiskTime
Time spent in pure raw disk IO.
TGaxis * fRealTimeAxis
Pointer to TGaxis object showing real-time.
Double_t fUnzipTime
Time spent uncompressing the data.
TPaveText * fPave
Pointer to annotation pavetext.
Int_t fTreeCacheSize
TTreeCache buffer size.
TGraphErrors * fGraphTime
Pointer to the graph with timestamp info.
TText * fHostInfoText
Graphics Text object with the fHostInfo data.
Long64_t fBytesReadExtra
Number of bytes (overhead) of the read-ahead cache.
void UnzipEvent(TObject *tree, Long64_t pos, Double_t start, Int_t complen, Int_t objlen) override
Record TTree unzip event.
TTreePerfStats()
default constructor (used when reading an object only)
A TTree represents a columnar dataset.
Provides the interface for the an internal performance measurement and event tracing.
Bool_t IsImplicitMTEnabled()
Returns true if the implicit multi-threading in ROOT is enabled.
T MaxElement(Long64_t n, const T *a)
Returns maximum of array a of length n.