Logo ROOT   6.14/05
Reference Guide
TTreePerfStats.h
Go to the documentation of this file.
1 // @(#)root/treeplayer:$Id$
2 // Author: Rene Brun 29/10/09
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2009, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TTreePerfStats
13 #define ROOT_TTreePerfStats
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // TTreePerfStats //
18 // //
19 // TTree I/O performance measurement //
20 // //
21 //////////////////////////////////////////////////////////////////////////
22 
23 
24 #include "TVirtualPerfStats.h"
25 #include "TString.h"
26 #include <vector>
27 #include <unordered_map>
28 
29 class TBrowser;
30 class TFile;
31 class TTree;
32 class TStopwatch;
33 class TPaveText;
34 class TGraphErrors;
35 class TGaxis;
36 class TText;
38 
39 public:
40  struct BasketInfo {
41  UInt_t fUsed = {0}; // Number of times the basket was requested from the disk.
42  UInt_t fLoaded = {0}; // Number of times the basket was put in the primary TTreeCache
43  UInt_t fLoadedMiss = {0}; // Number of times the basket was put in the secondary cache
44  UInt_t fMissed = {0}; // Number of times the basket was read directly from the file.
45  };
46 
47  using BasketList_t = std::vector<std::pair<TBranch*, std::vector<size_t>>>;
48 
49 protected:
50  Int_t fTreeCacheSize; //TTreeCache buffer size
51  Int_t fNleaves; //Number of leaves in the tree
52  Int_t fReadCalls; //Number of read calls
53  Int_t fReadaheadSize; //Readahead cache size
54  Long64_t fBytesRead; //Number of bytes read
55  Long64_t fBytesReadExtra;//Number of bytes (overhead) of the readahead cache
56  Double_t fRealNorm; //Real time scale factor for fGraphTime
57  Double_t fRealTime; //Real time
58  Double_t fCpuTime; //Cpu time
59  Double_t fDiskTime; //Time spent in pure raw disk IO
60  Double_t fUnzipTime; //Time spent uncompressing the data.
61  Double_t fCompress; //Tree compression factor
62  TString fName; //name of this TTreePerfStats
63  TString fHostInfo; //name of the host system, ROOT version and date
64  TFile *fFile; //!pointer to the file containing the Tree
65  TTree *fTree; //!pointer to the Tree being monitored
66  TGraphErrors *fGraphIO ; //pointer to the graph with IO data
67  TGraphErrors *fGraphTime ; //pointer to the graph with timestamp info
68  TPaveText *fPave; //pointer to annotation pavetext
69  TStopwatch *fWatch; //TStopwatch pointer
70  TGaxis *fRealTimeAxis; //pointer to TGaxis object showing real-time
71  TText *fHostInfoText; //Graphics Text object with the fHostInfo data
72 
73  std::unordered_map<TBranch*, size_t> fBranchIndexCache; // Cache the index of the branch in the cache's array.
74  std::vector<std::vector<BasketInfo> > fBasketsInfo; // Details on which baskets was used, cached, 'miss-cached' or read uncached.Browse
75 
76  BasketInfo &GetBasketInfo(TBranch *b, size_t basketNumber);
77  BasketInfo &GetBasketInfo(size_t bi, size_t basketNumber);
78 
79 public:
81  TTreePerfStats(const char *name, TTree *T);
82  virtual ~TTreePerfStats();
83  virtual void Browse(TBrowser *b);
84  virtual Int_t DistancetoPrimitive(Int_t px, Int_t py);
85  virtual void Draw(Option_t *option="");
86  virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py);
87  virtual void Finish();
88  virtual Long64_t GetBytesRead() const {return fBytesRead;}
89  virtual Long64_t GetBytesReadExtra() const {return fBytesReadExtra;}
90  virtual Double_t GetCpuTime() const {return fCpuTime;}
91  virtual Double_t GetDiskTime() const {return fDiskTime;}
94  const char *GetHostInfo() const{return fHostInfo.Data();}
95  const char *GetName() const{return fName.Data();}
96  virtual Int_t GetNleaves() const {return fNleaves;}
97  virtual Long64_t GetNumEvents() const {return 0;}
98  TPaveText *GetPave() {return fPave;}
99  virtual Int_t GetReadaheadSize() const {return fReadaheadSize;}
100  virtual Int_t GetReadCalls() const {return fReadCalls;}
101  virtual Double_t GetRealTime() const {return fRealTime;}
102  TStopwatch *GetStopwatch() const {return fWatch;}
103  virtual Int_t GetTreeCacheSize() const {return fTreeCacheSize;}
104  virtual Double_t GetUnzipTime() const {return fUnzipTime; }
105  virtual void Paint(Option_t *chopt="");
106  virtual void Print(Option_t *option="") const;
107 
108  virtual void SimpleEvent(EEventType) {}
109  virtual void PacketEvent(const char *, const char *, const char *,
111  virtual void FileEvent(const char *, const char *, const char *, const char *, Bool_t) {}
112  virtual void FileOpenEvent(TFile *, const char *, Double_t) {}
113  virtual void FileReadEvent(TFile *file, Int_t len, Double_t start);
114  virtual void UnzipEvent(TObject *tree, Long64_t pos, Double_t start, Int_t complen, Int_t objlen);
115  virtual void RateEvent(Double_t , Double_t , Long64_t , Long64_t) {}
116 
117  virtual void SaveAs(const char *filename="",Option_t *option="") const;
118  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
119  virtual void SetBytesRead(Long64_t nbytes) {fBytesRead = nbytes;}
120  virtual void SetBytesReadExtra(Long64_t nbytes) {fBytesReadExtra = nbytes;}
121  virtual void SetCompress(Double_t cx) {fCompress = cx;}
122  virtual void SetDiskTime(Double_t t) {fDiskTime = t;}
123  virtual void SetNumEvents(Long64_t) {}
124  virtual void SetCpuTime(Double_t cptime) {fCpuTime = cptime;}
125  virtual void SetGraphIO(TGraphErrors *gr) {fGraphIO = gr;}
126  virtual void SetGraphTime(TGraphErrors *gr) {fGraphTime = gr;}
127  virtual void SetHostInfo(const char *info) {fHostInfo = info;}
128  virtual void SetName(const char *name) {fName = name;}
129  virtual void SetNleaves(Int_t nleaves) {fNleaves = nleaves;}
130  virtual void SetReadaheadSize(Int_t nbytes) {fReadaheadSize = nbytes;}
131  virtual void SetReadCalls(Int_t ncalls) {fReadCalls = ncalls;}
132  virtual void SetRealNorm(Double_t rnorm) {fRealNorm = rnorm;}
133  virtual void SetRealTime(Double_t rtime) {fRealTime = rtime;}
134  virtual void SetTreeCacheSize(Int_t nbytes) {fTreeCacheSize = nbytes;}
135  virtual void SetUnzipTime(Double_t uztime) {fUnzipTime = uztime;}
136 
137  virtual void PrintBasketInfo(Option_t *option = "") const;
138  virtual void SetLoaded(TBranch *b, size_t basketNumber) { ++GetBasketInfo(b, basketNumber).fLoaded; }
139  virtual void SetLoaded(size_t bi, size_t basketNumber) { ++GetBasketInfo(bi, basketNumber).fLoaded; }
140  virtual void SetLoadedMiss(TBranch *b, size_t basketNumber) { ++GetBasketInfo(b, basketNumber).fLoadedMiss; }
141  virtual void SetLoadedMiss(size_t bi, size_t basketNumber) { ++GetBasketInfo(bi, basketNumber).fLoadedMiss; }
142  virtual void SetMissed(TBranch *b, size_t basketNumber) { ++GetBasketInfo(b, basketNumber).fMissed; }
143  virtual void SetMissed(size_t bi, size_t basketNumber) { ++GetBasketInfo(bi, basketNumber).fMissed; }
144  virtual void SetUsed(TBranch *b, size_t basketNumber) { ++GetBasketInfo(b, basketNumber).fUsed; }
145  virtual void SetUsed(size_t bi, size_t basketNumber) { ++GetBasketInfo(bi, basketNumber).fUsed; }
146  virtual void UpdateBranchIndices(TObjArray *branchNames);
147 
149 
150  ClassDef(TTreePerfStats, 7) // TTree I/O performance measurement
151 };
152 
153 #endif
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Return distance to one of the objects in the TTreePerfStats.
virtual void Browse(TBrowser *b)
Browse.
virtual void SetBytesReadExtra(Long64_t nbytes)
virtual void SetDiskTime(Double_t t)
An array of TObjects.
Definition: TObjArray.h:37
Long64_t fBytesRead
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Return distance to one of the objects in the TTreePerfStats.
virtual void FileReadEvent(TFile *file, Int_t len, Double_t start)
Record TTree file read event.
virtual Int_t GetReadCalls() const
long long Long64_t
Definition: RtypesCore.h:69
TPaveText * GetPave()
TGraphErrors * fGraphIO
pointer to the Tree being monitored
TGraphErrors * GetGraphTime()
virtual void SetNumEvents(Long64_t)
Provides the interface for the PROOF internal performance measurement and event tracing.
virtual void FileOpenEvent(TFile *, const char *, Double_t)
const char Option_t
Definition: RtypesCore.h:62
virtual void Finish()
When the run is finished this function must be called to save the current parameters in the file and ...
virtual void SetReadaheadSize(Int_t nbytes)
double T(double x)
Definition: ChebyshevPol.h:34
virtual void Print(Option_t *option="") const
Print the TTree I/O perf stats.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:47
virtual void UpdateBranchIndices(TObjArray *branchNames)
Update the fBranchIndexCache collection to match the current TTree given the ordered list of branch n...
Long64_t fBytesReadExtra
const char * GetHostInfo() const
Double_t fRealTime
virtual Double_t GetUnzipTime() const
Basic string class.
Definition: TString.h:131
virtual void SaveAs(const char *filename="", Option_t *option="") const
Save this object to filename.
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual void SetLoaded(size_t bi, size_t basketNumber)
virtual void SetLoadedMiss(TBranch *b, size_t basketNumber)
virtual void SimpleEvent(EEventType)
BasketList_t GetDuplicateBasketCache() const
Return the collection of baskets which have been read by the TTreeCache more than once...
virtual void RateEvent(Double_t, Double_t, Long64_t, Long64_t)
virtual void SetCpuTime(Double_t cptime)
TGaxis * fRealTimeAxis
#define ClassDef(name, id)
Definition: Rtypes.h:320
virtual void SetTreeCacheSize(Int_t nbytes)
Double_t fUnzipTime
virtual void SetLoadedMiss(size_t bi, size_t basketNumber)
virtual void SetBytesRead(Long64_t nbytes)
Base class for several text objects.
Definition: TText.h:23
virtual void PrintBasketInfo(Option_t *option="") const
Print the TTree basket information.
virtual void SetCompress(Double_t cx)
virtual void SetRealTime(Double_t rtime)
virtual void SetGraphTime(TGraphErrors *gr)
virtual void FileEvent(const char *, const char *, const char *, const char *, Bool_t)
std::unordered_map< TBranch *, size_t > fBranchIndexCache
TStopwatch * GetStopwatch() const
Double_t fDiskTime
virtual void SetGraphIO(TGraphErrors *gr)
const char * GetName() const
Returns name of object.
virtual void SetMissed(TBranch *b, size_t basketNumber)
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
virtual Int_t GetNleaves() const
std::vector< std::pair< TBranch *, std::vector< size_t > >> BasketList_t
virtual Double_t GetRealTime() const
std::vector< std::vector< BasketInfo > > fBasketsInfo
Double_t fCompress
virtual void SetName(const char *name)
virtual void UnzipEvent(TObject *tree, Long64_t pos, Double_t start, Int_t complen, Int_t objlen)
Record TTree unzip event.
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual ~TTreePerfStats()
Destructor.
virtual Double_t GetCpuTime() const
virtual void SetReadCalls(Int_t ncalls)
The axis painter class.
Definition: TGaxis.h:24
virtual void SetLoaded(TBranch *b, size_t basketNumber)
TTree I/O performance measurement.
TStopwatch * fWatch
TGraphErrors * gr
Definition: legend1.C:25
virtual void SetUsed(TBranch *b, size_t basketNumber)
TGraphErrors * GetGraphIO()
Double_t fCpuTime
virtual void SetNleaves(Int_t nleaves)
A Pave (see TPave) with text, lines or/and boxes inside.
Definition: TPaveText.h:21
virtual void SetRealNorm(Double_t rnorm)
virtual Long64_t GetNumEvents() const
virtual void SetUnzipTime(Double_t uztime)
double Double_t
Definition: RtypesCore.h:55
virtual Int_t GetTreeCacheSize() const
virtual void PacketEvent(const char *, const char *, const char *, Long64_t, Double_t, Double_t, Double_t, Long64_t)
Mother of all ROOT objects.
Definition: TObject.h:37
TText * fHostInfoText
virtual void SetHostInfo(const char *info)
virtual void Paint(Option_t *chopt="")
Draw the TTree I/O perf graph.
virtual Long64_t GetBytesRead() const
Definition: file.py:1
TTree * fTree
pointer to the file containing the Tree
Double_t fRealNorm
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
A TGraphErrors is a TGraph with error bars.
Definition: TGraphErrors.h:26
Definition: tree.py:1
TTreePerfStats()
default constructor (used when reading an object only)
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
A TTree object has a header with a name and a title.
Definition: TTree.h:70
virtual Long64_t GetBytesReadExtra() const
virtual void SetUsed(size_t bi, size_t basketNumber)
virtual Int_t GetReadaheadSize() const
A TTree is a list of TBranches.
Definition: TBranch.h:62
TGraphErrors * fGraphTime
virtual Double_t GetDiskTime() const
char name[80]
Definition: TGX11.cxx:109
virtual void Draw(Option_t *option="")
Draw the TTree I/O perf graph.
virtual void SetMissed(size_t bi, size_t basketNumber)
BasketInfo & GetBasketInfo(TBranch *b, size_t basketNumber)
Return the BasketInfo corresponding to the given branch and basket.
TPaveText * fPave
const char * Data() const
Definition: TString.h:364
Stopwatch class.
Definition: TStopwatch.h:28