Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
29class TBrowser;
30class TFile;
31class TTree;
32class TStopwatch;
33class TPaveText;
34class TGraphErrors;
35class TGaxis;
36class TText;
37
39
40public:
41 struct BasketInfo {
42 UInt_t fUsed = {0}; ///< Number of times the basket was requested from the disk.
43 UInt_t fLoaded = {0}; ///< Number of times the basket was put in the primary TTreeCache
44 UInt_t fLoadedMiss = {0}; ///< Number of times the basket was put in the secondary cache
45 UInt_t fMissed = {0}; ///< Number of times the basket was read directly from the file.
46 };
47
48 using BasketList_t = std::vector<std::pair<TBranch*, std::vector<size_t>>>;
49
50protected:
51 Int_t fTreeCacheSize; ///< TTreeCache buffer size
52 Int_t fNleaves; ///< Number of leaves in the tree
53 Int_t fReadCalls; ///< Number of read calls
54 Int_t fReadaheadSize; ///< Read-ahead cache size
55 Long64_t fBytesRead; ///< Number of bytes read
56 Long64_t fBytesReadExtra;///< Number of bytes (overhead) of the read-ahead cache
57 Double_t fRealNorm; ///< Real time scale factor for fGraphTime
58 Double_t fRealTime; ///< Real time
59 Double_t fCpuTime; ///< Cpu time
60 Double_t fDiskTime; ///< Time spent in pure raw disk IO
61 Double_t fUnzipTime; ///< Time spent uncompressing the data.
62 Long64_t fUnzipInputSize;///< Compressed bytes seen by the decompressor.
63 Long64_t fUnzipObjSize; ///< Uncompressed bytes produced by the decompressor.
64 Double_t fCompress; ///< Tree compression factor
65 TString fName; ///< Name of this TTreePerfStats
66 TString fHostInfo; ///< Name of the host system, ROOT version and date
67 TFile *fFile; ///<! Pointer to the file containing the Tree
68 TTree *fTree; ///<! Pointer to the Tree being monitored
69 TGraphErrors *fGraphIO ; ///< Pointer to the graph with IO data
70 TGraphErrors *fGraphTime ; ///< Pointer to the graph with timestamp info
71 TPaveText *fPave; ///< Pointer to annotation pavetext
72 TStopwatch *fWatch; ///< TStopwatch pointer
73 TGaxis *fRealTimeAxis; ///< Pointer to TGaxis object showing real-time
74 TText *fHostInfoText; ///< Graphics Text object with the fHostInfo data
75
76 std::unordered_map<TBranch*, size_t> fBranchIndexCache; // Cache the index of the branch in the cache's array.
77 std::vector<std::vector<BasketInfo> > fBasketsInfo; // Details on which baskets was used, cached, 'miss-cached' or read uncached.Browse
78
79 BasketInfo &GetBasketInfo(TBranch *b, size_t basketNumber);
80 BasketInfo &GetBasketInfo(size_t bi, size_t basketNumber);
81
82 void SetFile(TFile *newfile) override {
83 fFile = newfile;
84 }
85
86public:
88 TTreePerfStats(const char *name, TTree *T);
89 ~TTreePerfStats() override;
90 void Browse(TBrowser *b) override;
91 Int_t DistancetoPrimitive(Int_t px, Int_t py) override;
92 void Draw(Option_t *option="") override;
93 void ExecuteEvent(Int_t event, Int_t px, Int_t py) override;
94 virtual void Finish();
95 Long64_t GetBytesRead() const override {return fBytesRead;}
96 virtual Long64_t GetBytesReadExtra() const {return fBytesReadExtra;}
97 virtual Double_t GetCpuTime() const {return fCpuTime;}
98 virtual Double_t GetDiskTime() const {return fDiskTime;}
101 const char *GetHostInfo() const{return fHostInfo.Data();}
102 const char *GetName() const override{return fName.Data();}
103 virtual Int_t GetNleaves() const {return fNleaves;}
104 Long64_t GetNumEvents() const override {return 0;}
106 virtual Int_t GetReadaheadSize() const {return fReadaheadSize;}
107 virtual Int_t GetReadCalls() const {return fReadCalls;}
108 virtual Double_t GetRealTime() const {return fRealTime;}
109 TStopwatch *GetStopwatch() const {return fWatch;}
110 virtual Int_t GetTreeCacheSize() const {return fTreeCacheSize;}
111 virtual Double_t GetUnzipTime() const {return fUnzipTime; }
112 void Paint(Option_t *chopt="") override;
113 void Print(Option_t *option="") const override;
114
115 void SimpleEvent(EEventType) override {}
116 void PacketEvent(const char *, const char *, const char *,
117 Long64_t , Double_t ,Double_t , Double_t ,Long64_t ) override {}
118 void FileEvent(const char *, const char *, const char *, const char *, bool) override {}
119 void FileOpenEvent(TFile *, const char *, Double_t) override {}
120 void FileReadEvent(TFile *file, Int_t len, Double_t start) override;
121 void UnzipEvent(TObject *tree, Long64_t pos, Double_t start, Int_t complen, Int_t objlen) override;
123
124 void SaveAs(const char *filename="",Option_t *option="") const override;
125 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
126 void SetBytesRead(Long64_t nbytes) override {fBytesRead = nbytes;}
127 virtual void SetBytesReadExtra(Long64_t nbytes) {fBytesReadExtra = nbytes;}
128 virtual void SetCompress(Double_t cx) {fCompress = cx;}
129 virtual void SetDiskTime(Double_t t) {fDiskTime = t;}
130 void SetNumEvents(Long64_t) override {}
131 virtual void SetCpuTime(Double_t cptime) {fCpuTime = cptime;}
134 virtual void SetHostInfo(const char *info) {fHostInfo = info;}
135 virtual void SetName(const char *name) {fName = name;}
136 virtual void SetNleaves(Int_t nleaves) {fNleaves = nleaves;}
137 virtual void SetReadaheadSize(Int_t nbytes) {fReadaheadSize = nbytes;}
138 virtual void SetReadCalls(Int_t ncalls) {fReadCalls = ncalls;}
139 virtual void SetRealNorm(Double_t rnorm) {fRealNorm = rnorm;}
140 virtual void SetRealTime(Double_t rtime) {fRealTime = rtime;}
141 virtual void SetTreeCacheSize(Int_t nbytes) {fTreeCacheSize = nbytes;}
142 virtual void SetUnzipTime(Double_t uztime) {fUnzipTime = uztime;}
143
144 void PrintBasketInfo(Option_t *option = "") const override;
145 void SetLoaded(TBranch *b, size_t basketNumber) override { ++GetBasketInfo(b, basketNumber).fLoaded; }
146 void SetLoaded(size_t bi, size_t basketNumber) override { ++GetBasketInfo(bi, basketNumber).fLoaded; }
147 void SetLoadedMiss(TBranch *b, size_t basketNumber) override { ++GetBasketInfo(b, basketNumber).fLoadedMiss; }
148 void SetLoadedMiss(size_t bi, size_t basketNumber) override { ++GetBasketInfo(bi, basketNumber).fLoadedMiss; }
149 void SetMissed(TBranch *b, size_t basketNumber) override { ++GetBasketInfo(b, basketNumber).fMissed; }
150 void SetMissed(size_t bi, size_t basketNumber) override { ++GetBasketInfo(bi, basketNumber).fMissed; }
151 void SetUsed(TBranch *b, size_t basketNumber) override { ++GetBasketInfo(b, basketNumber).fUsed; }
152 void SetUsed(size_t bi, size_t basketNumber) override { ++GetBasketInfo(bi, basketNumber).fUsed; }
153 void UpdateBranchIndices(TObjArray *branchNames) override;
154
156
157 ClassDefOverride(TTreePerfStats, 8) // TTree I/O performance measurement
158};
159
160#endif
#define b(i)
Definition RSha256.hxx:100
int Int_t
Definition RtypesCore.h:45
double Double_t
Definition RtypesCore.h:59
long long Long64_t
Definition RtypesCore.h:80
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
char name[80]
Definition TGX11.cxx:110
A TTree is a list of TBranches.
Definition TBranch.h:93
Using a TBrowser one can browse all ROOT objects.
Definition TBrowser.h:37
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Definition TFile.h:53
The axis painter class.
Definition TGaxis.h:24
A TGraphErrors is a TGraph with error bars.
An array of TObjects.
Definition TObjArray.h:31
Mother of all ROOT objects.
Definition TObject.h:41
A Pave (see TPave) with text, lines or/and boxes inside.
Definition TPaveText.h:21
Stopwatch class.
Definition TStopwatch.h:28
Basic string class.
Definition TString.h:139
const char * Data() const
Definition TString.h:376
Base class for several text objects.
Definition TText.h:22
TTree I/O performance measurement.
TGraphErrors * fGraphIO
Pointer to the graph with IO data.
Long64_t GetNumEvents() const override
Long64_t fUnzipInputSize
Compressed bytes seen by the decompressor.
void SetUsed(size_t bi, size_t basketNumber) override
virtual void SetGraphIO(TGraphErrors *gr)
TPaveText * GetPave()
void SetUsed(TBranch *b, size_t basketNumber) override
virtual void SetRealNorm(Double_t rnorm)
TString fName
Name of this TTreePerfStats.
Int_t fNleaves
Number of leaves in the tree.
Long64_t GetBytesRead() const override
virtual void SetName(const char *name)
void Browse(TBrowser *b) override
Browse.
virtual void SetCompress(Double_t cx)
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Return distance to one of the objects in the TTreePerfStats.
void RateEvent(Double_t, Double_t, Long64_t, Long64_t) override
virtual void SetBytesReadExtra(Long64_t nbytes)
void SetLoaded(size_t bi, size_t basketNumber) override
void SetNumEvents(Long64_t) override
Double_t fRealNorm
Real time scale factor for fGraphTime.
void FileEvent(const char *, const char *, const char *, const char *, bool) override
BasketInfo & GetBasketInfo(TBranch *b, size_t basketNumber)
Return the BasketInfo corresponding to the given branch and basket.
void PacketEvent(const char *, const char *, const char *, Long64_t, Double_t, Double_t, Double_t, Long64_t) override
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
virtual void SetReadaheadSize(Int_t nbytes)
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.
TStopwatch * GetStopwatch() const
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...
void SetLoaded(TBranch *b, size_t basketNumber) override
TGraphErrors * GetGraphTime()
BasketList_t GetDuplicateBasketCache() const
Return the collection of baskets which have been read by the TTreeCache more than once.
void SetMissed(size_t bi, size_t basketNumber) override
Double_t fCpuTime
Cpu time.
virtual Double_t GetCpuTime() const
void SetFile(TFile *newfile) override
void SimpleEvent(EEventType) override
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.
virtual Long64_t GetBytesReadExtra() const
virtual void SetTreeCacheSize(Int_t nbytes)
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.
virtual Int_t GetReadCalls() const
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.
virtual Int_t GetReadaheadSize() const
TFile * fFile
! Pointer to the file containing the Tree
const char * GetHostInfo() const
virtual Double_t GetUnzipTime() 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.
void SetLoadedMiss(size_t bi, size_t basketNumber) override
virtual Double_t GetRealTime() const
virtual void SetUnzipTime(Double_t uztime)
virtual void SetReadCalls(Int_t ncalls)
virtual Double_t GetDiskTime() const
std::unordered_map< TBranch *, size_t > fBranchIndexCache
~TTreePerfStats() override
Destructor.
void FileOpenEvent(TFile *, const char *, Double_t) override
virtual void SetGraphTime(TGraphErrors *gr)
Double_t fDiskTime
Time spent in pure raw disk IO.
TGaxis * fRealTimeAxis
Pointer to TGaxis object showing real-time.
virtual Int_t GetNleaves() const
Double_t fUnzipTime
Time spent uncompressing the data.
std::vector< std::pair< TBranch *, std::vector< size_t > > > BasketList_t
TPaveText * fPave
Pointer to annotation pavetext.
Int_t fTreeCacheSize
TTreeCache buffer size.
virtual Int_t GetTreeCacheSize() const
void SetLoadedMiss(TBranch *b, size_t basketNumber) override
virtual void SetRealTime(Double_t rtime)
TGraphErrors * fGraphTime
Pointer to the graph with timestamp info.
virtual void SetDiskTime(Double_t t)
void SetBytesRead(Long64_t nbytes) override
virtual void SetNleaves(Int_t nleaves)
TGraphErrors * GetGraphIO()
TText * fHostInfoText
Graphics Text object with the fHostInfo data.
void SetMissed(TBranch *b, size_t basketNumber) override
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.
virtual void SetCpuTime(Double_t cptime)
TTreePerfStats()
default constructor (used when reading an object only)
virtual void SetHostInfo(const char *info)
A TTree represents a columnar dataset.
Definition TTree.h:79
Provides the interface for the PROOF internal performance measurement and event tracing.
TGraphErrors * gr
Definition legend1.C:25
UInt_t fMissed
Number of times the basket was read directly from the file.
UInt_t fLoaded
Number of times the basket was put in the primary TTreeCache.
UInt_t fLoadedMiss
Number of times the basket was put in the secondary cache.
UInt_t fUsed
Number of times the basket was requested from the disk.
th1 Draw()