Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TTreePerfStats.cxx
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/** \class TTreePerfStats
13
14TTree I/O performance measurement. see example of use below.
15
16The function FileReadEvent is called from TFile::ReadBuffer.
17For each call the following information is stored in fGraphIO
18 - x[i] = Tree entry number
19 - y[i] = 1e-6*(file position)
20 - ey[i] = 1e-9*number of bytes read
21For each call the following information is stored in fGraphTime
22 - x[i] = Tree entry number
23 - y[i] = Time now
24 - ey[i] = readtime, eg timenow - start
25The TTreePerfStats object can be saved in a ROOT file in such a way that
26its inspection can be done outside the job that generated it.
27
28Example of use:
29~~~{.cpp}
30{
31 TFile *f = TFile::Open("RelValMinBias-GEN-SIM-RECO.root");
32 T = (TTree*)f->Get("Events");
33 Long64_t nentries = T->GetEntries();
34 T->SetCacheSize(10000000);
35 T->SetCacheEntryRange(0,nentries);
36 T->AddBranchToCache("*");
37//
38 TTreePerfStats *ps= new TTreePerfStats("ioperf",T);
39//
40 for (Int_t i=0;i<nentries;i++) {
41 T->GetEntry(i);
42 }
43 ps->SaveAs("cmsperf.root");
44}
45~~~
46then, in a root interactive session, one can do:
47~~~{.cpp}
48 root > TFile f("cmsperf.root");
49 root > ioperf->Draw();
50 root > ioperf->Print();
51~~~
52The Draw or Print functions print the following information:
53 - TreeCache = TTree cache size in MBytes
54 - N leaves = Number of leaves in the TTree
55 - ReadTotal = Total number of zipped bytes read
56 - ReadUnZip = Total number of unzipped bytes read
57 - ReadCalls = Total number of disk reads
58 - ReadSize = Average read size in KBytes
59 - Readahead = Readahead size in KBytes
60 - Readextra = Readahead overhead in percent
61 - Real Time = Real Time in seconds
62 - CPU Time = CPU Time in seconds
63 - Disk Time = Real Time spent in pure raw disk IO
64 - Disk IO = Raw disk IO speed in MBytes/second
65 - ReadUZRT = Unzipped MBytes per RT second
66 - ReadUZCP = Unipped MBytes per CP second
67 - ReadRT = Zipped MBytes per RT second
68 - ReadCP = Zipped MBytes per CP second
69
70 ### NOTE 1 :
71The ReadTotal value indicates the effective number of zipped bytes
72returned to the application. The physical number of bytes read
73from the device (as measured for example with strace) is
74ReadTotal +ReadTotal*Readextra/100. Same for ReadSize.
75
76 ### NOTE 2 :
77A consequence of NOTE1, the Disk I/O speed corresponds to the effective
78number of bytes returned to the application per second.
79The Physical disk speed is DiskIO + DiskIO*ReadExtra/100.
80*/
81
82#include "TTreePerfStats.h"
83#include "TROOT.h"
84#include "TSystem.h"
85#include "TFile.h"
86#include "TTree.h"
87#include "TTreeCache.h"
88#include "TAxis.h"
89#include "TBranch.h"
90#include "TBrowser.h"
91#include "TVirtualPad.h"
92#include "TPaveText.h"
93#include "TGraphErrors.h"
94#include "TStopwatch.h"
95#include "TGaxis.h"
96#include "TTimeStamp.h"
97#include "TDatime.h"
98#include "TMath.h"
99
100#include <iostream>
101
103
104////////////////////////////////////////////////////////////////////////////////
105/// default constructor (used when reading an object only)
106
108{
109 fName = "";
110 fHostInfo = "";
111 fTree = nullptr;
112 fNleaves = 0;
113 fFile = nullptr;
114 fGraphIO = nullptr;
115 fGraphTime = nullptr;
116 fWatch = nullptr;
117 fPave = nullptr;
118 fTreeCacheSize = 0;
119 fReadCalls = 0;
120 fReadaheadSize = 0;
121 fBytesRead = 0;
123 fRealNorm = 0;
124 fRealTime = 0;
125 fCpuTime = 0;
126 fDiskTime = 0;
127 fUnzipTime = 0;
129 fUnzipObjSize = 0;
130 fCompress = 0;
131 fRealTimeAxis = nullptr;
132 fHostInfoText = nullptr;
133}
134
135////////////////////////////////////////////////////////////////////////////////
136/// Create a TTree I/O perf stats object.
137
139{
140 fName = name;
141 fTree = T;
142 T->SetPerfStats(this);
143 fNleaves= T->GetListOfLeaves()->GetEntries();
144 fFile = T->GetCurrentFile();
145 fGraphIO = new TGraphErrors(0);
146 fGraphIO->SetName("ioperf");
147 fGraphIO->SetTitle(Form("%s/%s",fFile->GetName(),T->GetName()));
148 fGraphIO->SetUniqueID(999999999);
149 fGraphTime = new TGraphErrors(0);
151 fGraphTime->SetName("iotime");
152 fGraphTime->SetTitle("Real time vs entries");
153 fWatch = new TStopwatch();
154 fWatch->Start();
155 fPave = nullptr;
156 fTreeCacheSize = 0;
157 fReadCalls = 0;
158 fReadaheadSize = 0;
159 fBytesRead = 0;
161 fRealNorm = 0;
162 fRealTime = 0;
163 fCpuTime = 0;
164 fDiskTime = 0;
165 fUnzipTime = 0;
167 fUnzipObjSize = 0;
168 fRealTimeAxis = nullptr;
169 fCompress = (T->GetTotBytes()+0.00001)/T->GetZipBytes();
170
171 bool isUNIX = strcmp(gSystem->GetName(), "Unix") == 0;
172 if (isUNIX)
173 fHostInfo = gSystem->GetFromPipe("uname -a");
174 else
175 fHostInfo = "Windows ";
176 fHostInfo.Resize(20);
177 fHostInfo += TString::Format("ROOT %s, Git: %s", gROOT->GetVersion(), gROOT->GetGitCommit());
178 TDatime dt;
179 fHostInfo += TString::Format(" %s",dt.AsString());
180 fHostInfoText = nullptr;
181
182 gPerfStats = this;
183}
184
185////////////////////////////////////////////////////////////////////////////////
186/// Destructor
187
189{
190 fTree = nullptr;
191 fFile = nullptr;
192 delete fGraphIO;
193 delete fGraphTime;
194 delete fPave;
195 delete fWatch;
196 delete fRealTimeAxis;
197 delete fHostInfoText;
198
199 if (gPerfStats == this) {
200 gPerfStats = nullptr;
201 }
202}
203
204
205////////////////////////////////////////////////////////////////////////////////
206/// Browse
207
209{
210 Draw();
211 gPad->Update();
212}
213
214////////////////////////////////////////////////////////////////////////////////
215/// Return distance to one of the objects in the TTreePerfStats
216
218{
219 const Int_t kMaxDiff = 7;
220 Int_t puxmin = gPad->XtoAbsPixel(gPad->GetUxmin());
221 Int_t puymin = gPad->YtoAbsPixel(gPad->GetUymin());
222 Int_t puxmax = gPad->XtoAbsPixel(gPad->GetUxmax());
223 Int_t puymax = gPad->YtoAbsPixel(gPad->GetUymax());
224 if (py < puymax) return 9999;
225 //on the fGraphIO ?
226 Int_t distance = fGraphIO->DistancetoPrimitive(px,py);
227 if (distance <kMaxDiff) {if (px > puxmin && py < puymin) gPad->SetSelected(fGraphIO); return distance;}
228 // on the fGraphTime ?
229 distance = fGraphTime->DistancetoPrimitive(px,py);
230 if (distance <kMaxDiff) {if (px > puxmin && py < puymin) gPad->SetSelected(fGraphTime); return distance;}
231 // on the pave ?
232 distance = fPave->DistancetoPrimitive(px,py);
233 if (distance <kMaxDiff) {gPad->SetSelected(fPave); return distance;}
234 // on the real time axis ?
235 distance = fRealTimeAxis->DistancetoPrimitive(px,py);
236 if (distance <kMaxDiff) {gPad->SetSelected(fRealTimeAxis); return distance;}
237 // on the host info label ?
238 distance = fHostInfoText->DistancetoPrimitive(px,py);
239 if (distance <kMaxDiff) {gPad->SetSelected(fHostInfoText); return distance;}
240 if (px > puxmax-300) return 2;
241 return 999;
242}
243
244////////////////////////////////////////////////////////////////////////////////
245/// Draw the TTree I/O perf graph.
246/// by default the graph is drawn with option "al"
247/// Specify option ="ap" to show only the read blocks and not the line
248/// connecting the blocks
249
251{
252 Finish();
253
254 TString opt = option;
255 if (strlen(option)==0) opt = "al";
256 opt.ToLower();
257 if (gPad) {
258 if (!gPad->IsEditable()) gROOT->MakeDefCanvas();
259 //the following statement is necessary in case one attempts to draw
260 //a temporary histogram already in the current pad
261 if (TestBit(kCanDelete)) gPad->Remove(this);
262 } else {
263 gROOT->MakeDefCanvas();
264 }
265 if (opt.Contains("a")) {
266 gPad->SetLeftMargin(0.35);
267 gPad->Clear();
268 gPad->SetGridx();
269 gPad->SetGridy();
270 }
271 AppendPad(opt.Data());
272}
273
274////////////////////////////////////////////////////////////////////////////////
275/// Return distance to one of the objects in the TTreePerfStats
276
277void TTreePerfStats::ExecuteEvent(Int_t /*event*/, Int_t /*px*/, Int_t /*py*/)
278{
279}
280
281////////////////////////////////////////////////////////////////////////////////
282/// Record TTree file read event.
283/// - start is the TimeStamp before reading
284/// - len is the number of bytes read
285
287{
288 if (file == this->fFile) {
289 Long64_t offset = file->GetRelOffset();
290 Int_t np = fGraphIO->GetN();
291 Int_t entry = fTree->GetReadEntry();
292 fGraphIO->SetPoint(np,entry,1e-6*offset);
293 fGraphIO->SetPointError(np,0.001,1e-9*len);
294 Double_t tnow = TTimeStamp();
295 Double_t dtime = tnow-start;
296 fDiskTime += dtime;
297 fGraphTime->SetPoint(np,entry,tnow);
298 fGraphTime->SetPointError(np,0.001,dtime);
299 fReadCalls++;
300 fBytesRead += len;
301 }
302}
303
304
305////////////////////////////////////////////////////////////////////////////////
306/// Record TTree unzip event.
307/// - start is the TimeStamp before unzip
308/// - pos is where in the file the compressed buffer came from
309/// - complen is the length of the compressed buffer
310/// - objlen is the length of the de-compressed buffer
311
312void TTreePerfStats::UnzipEvent(TObject * tree, Long64_t /* pos */, Double_t start, Int_t complen, Int_t objlen)
313{
314 if (tree == this->fTree || tree == this->fTree->GetTree()){
315 Double_t tnow = TTimeStamp();
316 Double_t dtime = tnow-start;
317 fUnzipTime += dtime;
318 fUnzipInputSize += complen;
319 fUnzipObjSize += objlen;
320 }
321}
322
323////////////////////////////////////////////////////////////////////////////////
324/// When the run is finished this function must be called
325/// to save the current parameters in the file and Tree in this object
326/// the function is automatically called by Draw and Print
327
329{
330 if (fRealNorm) return; //has already been called
331 if (!fFile) return;
332 if (!fTree) return;
333
336 if (fTree->IsA()->InheritsFrom("TChain"))
338 else if (fFile)
342 if (fUnzipInputSize)
344 Int_t npoints = fGraphIO->GetN();
345 if (!npoints) return;
346 Double_t iomax = TMath::MaxElement(npoints,fGraphIO->GetY());
347 fRealNorm = iomax/fRealTime;
349 // we normalize the fGraphTime such that it can be drawn on top of fGraphIO
350 for (Int_t i=1;i<npoints;i++) {
351 fGraphTime->GetY()[i] = fGraphTime->GetY()[i-1] +fRealNorm*fGraphTime->GetEY()[i];
352 fGraphTime->GetEY()[i] = 0;
353 }
354}
355
356////////////////////////////////////////////////////////////////////////////////
357/// Update the fBranchIndexCache collection to match the current TTree given
358/// the ordered list of branch names.
359
361{
362 fBranchIndexCache.clear();
363
364 for (int i = 0; i < branches->GetEntries(); ++i) {
365 fBranchIndexCache.emplace((TBranch*)(branches->UncheckedAt(i)), i);
366 }
367}
368
369////////////////////////////////////////////////////////////////////////////////
370/// Return the BasketInfo corresponding to the given branch and basket.
371
373{
374 static BasketInfo fallback;
375
376 // First find the branch index.
377 TFile *file = fTree->GetCurrentFile();
378 if (!file)
379 return fallback;
380
381 TTreeCache *cache = dynamic_cast<TTreeCache *>(file->GetCacheRead(fTree));
382 if (!cache)
383 return fallback;
384
385 Int_t index = -1;
386 auto iter = fBranchIndexCache.find(br);
387 if (iter == fBranchIndexCache.end()) {
388 auto branches = cache->GetCachedBranches();
389 for (Int_t i = 0; i < branches->GetEntries(); ++i) {
390 if (br == branches->UncheckedAt(i)) {
391 index = i;
392 break;
393 }
394 }
395 if (index < 0)
396 return fallback;
397 fBranchIndexCache.emplace(br, index);
398 } else {
399 index = iter->second;
400 }
401
402 return GetBasketInfo(index, basketNumber);
403}
404
405////////////////////////////////////////////////////////////////////////////////
406/// Return the BasketInfo corresponding to the given branch and basket.
407
409{
410 if (fBasketsInfo.size() <= (size_t)index)
411 fBasketsInfo.resize(index + 1);
412
413 auto &brvec(fBasketsInfo[index]);
414 if (brvec.size() <= basketNumber)
415 brvec.resize(basketNumber + 1);
416
417 return brvec[basketNumber];
418}
419
420////////////////////////////////////////////////////////////////////////////////
421/// Return the collection of baskets which have been read by the TTreeCache more
422/// than once
423
425{
427
428 TFile *file = fTree->GetCurrentFile();
429 if (!file)
430 return result;
431
432 TTreeCache *cache = dynamic_cast<TTreeCache *>(file->GetCacheRead(fTree));
433 if (!cache)
434 return result;
435
436 auto branches = cache->GetCachedBranches();
437 for (size_t i = 0; i < fBasketsInfo.size(); ++i) {
438 bool first = true;
439 for (size_t j = 0; j < fBasketsInfo[i].size(); ++j) {
440 auto &info(fBasketsInfo[i][j]);
441 if ((info.fLoaded + info.fLoadedMiss) > 1) {
442 if (first) {
443 result.emplace_back(BasketList_t::value_type((TBranch*)branches->At(i), std::vector<size_t>(1)));
444 first = false;
445 }
446 auto &ref( result.back() );
447 ref.second.push_back(j);
448 }
449 }
450 }
451
452 return result;
453}
454
455////////////////////////////////////////////////////////////////////////////////
456/// Draw the TTree I/O perf graph.
457
459{
460 Int_t npoints = fGraphIO->GetN();
461 if (!npoints) return;
462 Double_t iomax = fGraphIO->GetY()[npoints-1];
463 Double_t toffset=1;
464 if (iomax >= 1e9) toffset = 1.2;
465 fGraphIO->GetXaxis()->SetTitle("Tree entry number");
466 fGraphIO->GetYaxis()->SetTitle("file position (MBytes) ");
467 fGraphIO->GetYaxis()->SetTitleOffset(toffset);
471
472 TString opts(option);
473 opts.ToLower();
474 bool unzip = opts.Contains("unzip");
475
476 //superimpose the time info (max 10 points)
477 if (fGraphTime) {
478 fGraphTime->Paint("l");
479 TText tdisk(fGraphTime->GetX()[npoints-1],1.1*fGraphTime->GetY()[npoints-1],"RAW IO");
480 tdisk.SetTextAlign(31);
481 tdisk.SetTextSize(0.03);
482 tdisk.SetTextColor(kRed);
483 tdisk.Paint();
484 if (!fRealTimeAxis) {
485 Double_t uxmax = gPad->GetUxmax();
486 Double_t uymax = gPad->GetUymax();
487 Double_t rtmax = uymax/fRealNorm;
488 fRealTimeAxis = new TGaxis(uxmax,0,uxmax,uymax,0.,rtmax,510,"+L");
489 fRealTimeAxis->SetName("RealTimeAxis");
491 fRealTimeAxis->SetTitle("RealTime (s) ");
493 toffset = 1;
494 if (fRealTime >= 100) toffset = 1.2;
495 if (fRealTime >= 1000) toffset = 1.4;
499 }
501 }
502
504 if (!fPave) {
505 fPave = new TPaveText(.01,.10,.24,.90,"brNDC");
506 fPave->SetTextAlign(12);
507 fPave->AddText(Form("TreeCache = %d MB",fTreeCacheSize/1000000));
508 fPave->AddText(Form("N leaves = %d",fNleaves));
509 fPave->AddText(Form("ReadTotal = %g MB",1e-6*fBytesRead));
510 fPave->AddText(Form("ReadUnZip = %g MB",1e-6*fBytesRead*fCompress));
511 fPave->AddText(Form("ReadCalls = %d",fReadCalls));
512 fPave->AddText(Form("ReadSize = %7.3f KB",0.001*fBytesRead/fReadCalls));
513 fPave->AddText(Form("Readahead = %d KB",fReadaheadSize/1000));
514 fPave->AddText(Form("Readextra = %5.2f per cent",extra));
515 fPave->AddText(Form("Real Time = %7.3f s",fRealTime));
516 fPave->AddText(Form("CPU Time = %7.3f s",fCpuTime));
517 fPave->AddText(Form("Disk Time = %7.3f s",fDiskTime));
518 if (unzip) {
519 fPave->AddText(Form("UnzipTime = %7.3f s",fUnzipTime));
520 }
521 fPave->AddText(Form("Disk IO = %7.3f MB/s",1e-6*fBytesRead/fDiskTime));
522 fPave->AddText(Form("ReadUZRT = %7.3f MB/s",1e-6*fCompress*fBytesRead/fRealTime));
523 fPave->AddText(Form("ReadUZCP = %7.3f MB/s",1e-6*fCompress*fBytesRead/fCpuTime));
524 fPave->AddText(Form("ReadRT = %7.3f MB/s",1e-6*fBytesRead/fRealTime));
525 fPave->AddText(Form("ReadCP = %7.3f MB/s",1e-6*fBytesRead/fCpuTime));
526 }
527 fPave->Paint();
528
529 if (!fHostInfoText) {
530 fHostInfoText = new TText(0.01,0.01,fHostInfo.Data());
533 }
535}
536
537////////////////////////////////////////////////////////////////////////////////
538/// Print the TTree I/O perf stats.
539
541{
542 TString opts(option);
543 opts.ToLower();
544 bool unzip = opts.Contains("unzip");
545 bool basket = opts.Contains("basket");
546 TTreePerfStats *ps = (TTreePerfStats*)this;
547 ps->Finish();
548
550 printf("TreeCache = %d MBytes\n",Int_t(fTreeCacheSize/1000000));
551 printf("N leaves = %d\n",fNleaves);
552 printf("ReadTotal = %g MBytes\n",1e-6*fBytesRead);
553 printf("ReadUnZip = %g MBytes\n",1e-6*fBytesRead*fCompress);
554 printf("ReadCalls = %d\n",fReadCalls);
555 printf("ReadSize = %7.3f KBytes/read\n",0.001*fBytesRead/fReadCalls);
556 printf("Readahead = %d KBytes\n",fReadaheadSize/1000);
557 printf("Readextra = %5.2f per cent\n",extra);
558 printf("Real Time = %7.3f seconds\n",fRealTime);
559 printf("CPU Time = %7.3f seconds\n",fCpuTime);
560 printf("Disk Time = %7.3f seconds\n",fDiskTime);
561 if (unzip) {
562 printf("Strm Time = %7.3f seconds\n",fCpuTime-fUnzipTime);
563 printf("UnzipTime = %7.3f seconds\n",fUnzipTime);
564 }
565 printf("Disk IO = %7.3f MBytes/s\n",1e-6*fBytesRead/fDiskTime);
566 printf("ReadUZRT = %7.3f MBytes/s\n",1e-6*fCompress*fBytesRead/fRealTime);
567 printf("ReadUZCP = %7.3f MBytes/s\n",1e-6*fCompress*fBytesRead/fCpuTime);
568 printf("ReadRT = %7.3f MBytes/s\n",1e-6*fBytesRead/fRealTime);
569 printf("ReadCP = %7.3f MBytes/s\n",1e-6*fBytesRead/fCpuTime);
570 if (unzip) {
571 printf("ReadStrCP = %7.3f MBytes/s\n",1e-6*fCompress*fBytesRead/(fCpuTime-fUnzipTime));
572 printf("ReadZipCP = %7.3f MBytes/s\n",1e-6*fCompress*fBytesRead/fUnzipTime);
573 }
574 if (basket)
576}
577
578////////////////////////////////////////////////////////////////////////////////
579/// Print the TTree basket information
580
582{
583
584 TString opts(option);
585 opts.ToLower();
586 bool all = opts.Contains("allbasketinfo");
587
588 TFile *file = fTree->GetCurrentFile();
589 if (!file)
590 return;
591
592 TTreeCache *cache = dynamic_cast<TTreeCache *>(file->GetCacheRead(fTree));
593 if (!cache)
594 return;
595
596 auto branches = cache->GetCachedBranches();
597 for (size_t i = 0; i < fBasketsInfo.size(); ++i) {
598 const char *branchname = branches->At(i)->GetName();
599
600 printf(" br=%zu %s read not cached: ", i, branchname);
601 if (fBasketsInfo[i].empty()) {
602 printf("none");
603 } else
604 for (size_t j = 0; j < fBasketsInfo[i].size(); ++j) {
605 if (fBasketsInfo[i][j].fMissed)
606 printf("%zu ", j);
607 }
608 printf("\n");
609
610 printf(" br=%zu %s cached more than once: ", i, branchname);
611 for (size_t j = 0; j < fBasketsInfo[i].size(); ++j) {
612 auto &info(fBasketsInfo[i][j]);
613 if ((info.fLoaded + info.fLoadedMiss) > 1)
614 printf("%zu[%d,%d] ", j, info.fLoaded, info.fLoadedMiss);
615 }
616 printf("\n");
617
618 printf(" br=%zu %s cached but not used: ", i, branchname);
619 for (size_t j = 0; j < fBasketsInfo[i].size(); ++j) {
620 auto &info(fBasketsInfo[i][j]);
621 if ((info.fLoaded + info.fLoadedMiss) && !info.fUsed) {
622 if (info.fLoadedMiss)
623 printf("%zu[%d,%d] ", j, info.fLoaded, info.fLoadedMiss);
624 else
625 printf("%zu ", j);
626 }
627 }
628 printf("\n");
629
630 if (all) {
631 printf(" br=%zu %s: ", i, branchname);
632 for (size_t j = 0; j < fBasketsInfo[i].size(); ++j) {
633 auto &info(fBasketsInfo[i][j]);
634 printf("%zu[%d,%d,%d,%d] ", j, info.fUsed, info.fLoaded, info.fLoadedMiss, info.fMissed);
635 }
636 printf("\n");
637 }
638 }
639 for (Int_t i = fBasketsInfo.size(); i < branches->GetEntries(); ++i) {
640 printf(" br=%d %s: no basket information\n", i, branches->At(i)->GetName());
641 }
642}
643
644////////////////////////////////////////////////////////////////////////////////
645/// Save this object to filename
646
647void TTreePerfStats::SaveAs(const char *filename, Option_t * /*option*/) const
648{
649 TTreePerfStats *ps = (TTreePerfStats*)this;
650 ps->Finish();
651 ps->TObject::SaveAs(filename);
652}
653
654////////////////////////////////////////////////////////////////////////////////
655/// Save primitive as a C++ statement(s) on output stream out
656
657void TTreePerfStats::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
658{
659 char quote = '"';
660 out<<" "<<std::endl;
661 if (gROOT->ClassSaved(TTreePerfStats::Class())) {
662 out<<" ";
663 } else {
664 out<<" TTreePerfStats *";
665 }
666 out<<"ps = new TTreePerfStats();"<<std::endl;
667 out<<" ps->SetName("<<quote<<GetName()<<quote<<");"<<std::endl;
668 out<<" ps->SetHostInfo("<<quote<<GetHostInfo()<<quote<<");"<<std::endl;
669 out<<" ps->SetTreeCacheSize("<<fTreeCacheSize<<");"<<std::endl;
670 out<<" ps->SetNleaves("<<fNleaves<<");"<<std::endl;
671 out<<" ps->SetReadCalls("<<fReadCalls<<");"<<std::endl;
672 out<<" ps->SetReadaheadSize("<<fReadaheadSize<<");"<<std::endl;
673 out<<" ps->SetBytesRead("<<fBytesRead<<");"<<std::endl;
674 out<<" ps->SetBytesReadExtra("<<fBytesReadExtra<<");"<<std::endl;
675 out<<" ps->SetRealNorm("<<fRealNorm<<");"<<std::endl;
676 out<<" ps->SetRealTime("<<fRealTime<<");"<<std::endl;
677 out<<" ps->SetCpuTime("<<fCpuTime<<");"<<std::endl;
678 out<<" ps->SetDiskTime("<<fDiskTime<<");"<<std::endl;
679 out<<" ps->SetUnzipTime("<<fUnzipTime<<");"<<std::endl;
680 out<<" ps->SetCompress("<<fCompress<<");"<<std::endl;
681
682 Int_t i, npoints = fGraphIO->GetN();
683 out<<" TGraphErrors *psGraphIO = new TGraphErrors("<<npoints<<");"<<std::endl;
684 out<<" psGraphIO->SetName("<<quote<<fGraphIO->GetName()<<quote<<");"<<std::endl;
685 out<<" psGraphIO->SetTitle("<<quote<<fGraphIO->GetTitle()<<quote<<");"<<std::endl;
686 out<<" ps->SetGraphIO(psGraphIO);"<<std::endl;
687 fGraphIO->SaveFillAttributes(out,"psGraphIO",0,1001);
688 fGraphIO->SaveLineAttributes(out,"psGraphIO",1,1,1);
689 fGraphIO->SaveMarkerAttributes(out,"psGraphIO",1,1,1);
690 for (i=0;i<npoints;i++) {
691 out<<" psGraphIO->SetPoint("<<i<<","<<fGraphIO->GetX()[i]<<","<<fGraphIO->GetY()[i]<<");"<<std::endl;
692 out<<" psGraphIO->SetPointError("<<i<<",0,"<<fGraphIO->GetEY()[i]<<");"<<std::endl;
693 }
694 npoints = fGraphTime->GetN();
695 out<<" TGraphErrors *psGraphTime = new TGraphErrors("<<npoints<<");"<<std::endl;
696 out<<" psGraphTime->SetName("<<quote<<fGraphTime->GetName()<<quote<<");"<<std::endl;
697 out<<" psGraphTime->SetTitle("<<quote<<fGraphTime->GetTitle()<<quote<<");"<<std::endl;
698 out<<" ps->SetGraphTime(psGraphTime);"<<std::endl;
699 fGraphTime->SaveFillAttributes(out,"psGraphTime",0,1001);
700 fGraphTime->SaveLineAttributes(out,"psGraphTime",1,1,1);
701 fGraphTime->SaveMarkerAttributes(out,"psGraphTime",1,1,1);
702 for (i=0;i<npoints;i++) {
703 out<<" psGraphTime->SetPoint("<<i<<","<<fGraphTime->GetX()[i]<<","<<fGraphTime->GetY()[i]<<");"<<std::endl;
704 out<<" psGraphTime->SetPointError("<<i<<",0,"<<fGraphTime->GetEY()[i]<<");"<<std::endl;
705 }
706
707 out<<" ps->Draw("<<quote<<option<<quote<<");"<<std::endl;
708}
#define e(i)
Definition RSha256.hxx:103
int Int_t
Definition RtypesCore.h:45
long long Long64_t
Definition RtypesCore.h:69
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:382
@ kRed
Definition Rtypes.h:66
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 offset
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 np
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 result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
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
#define gROOT
Definition TROOT.h:406
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2489
R__EXTERN TSystem * gSystem
Definition TSystem.h:561
#define gPad
#define gPerfStats
virtual void SetTitleOffset(Float_t offset=1)
Set distance between the axis and the axis title.
Definition TAttAxis.cxx:298
virtual void SetLabelSize(Float_t size=0.04)
Set size of axis labels.
Definition TAttAxis.cxx:203
virtual void SaveFillAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1001)
Save fill attributes as C++ statement(s) on output stream out.
Definition TAttFill.cxx:239
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition TAttLine.h:40
virtual void SaveLineAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t widdef=1)
Save line attributes as C++ statement(s) on output stream out.
Definition TAttLine.cxx:275
virtual void SaveMarkerAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t sizdef=1)
Save line attributes as C++ statement(s) on output stream out.
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
Definition TAttText.h:42
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
Definition TAttText.h:44
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Definition TAttText.h:47
A TTree is a list of TBranches.
Definition TBranch.h:93
Using a TBrowser one can browse all ROOT objects.
Definition TBrowser.h:37
Bool_t InheritsFrom(const char *cl) const override
Return kTRUE if this class inherits from a class with name "classname".
Definition TClass.cxx:4941
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition TDatime.h:37
const char * AsString() const
Return the date & time as a string (ctime() format).
Definition TDatime.cxx:102
virtual TFile * GetFile() const
Definition TDirectory.h:220
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Definition TFile.h:53
static Int_t GetReadaheadSize()
Static function returning the readahead buffer size.
Definition TFile.cxx:4599
Long64_t GetRelOffset() const
Definition TFile.h:251
virtual Long64_t GetBytesReadExtra() const
Definition TFile.h:242
TFileCacheRead * GetCacheRead(const TObject *tree=nullptr) const
Return a pointer to the current read cache.
Definition TFile.cxx:1262
The axis painter class.
Definition TGaxis.h:24
void SetTitleOffset(Float_t titleoffset=1)
Definition TGaxis.h:128
virtual void SetTitle(const char *title="")
Change the title of the axis.
Definition TGaxis.cxx:2942
void SetLabelColor(Int_t labelcolor)
Definition TGaxis.h:104
void SetTitleColor(Int_t titlecolor)
Definition TGaxis.h:131
void Paint(Option_t *chopt="") override
Draw this axis with its current attributes.
Definition TGaxis.cxx:986
void SetLabelSize(Float_t labelsize)
Definition TGaxis.h:107
virtual void SetName(const char *name)
Change the name of the axis.
Definition TGaxis.cxx:2904
A TGraphErrors is a TGraph with error bars.
virtual void SetPointError(Double_t ex, Double_t ey)
Set ex and ey values for point pointed by the mouse.
Double_t * GetEY() const override
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Set x and y values for point number i.
Definition TGraph.cxx:2342
Double_t * GetY() const
Definition TGraph.h:140
void Paint(Option_t *chopt="") override
Draw this graph with its current attributes.
Definition TGraph.cxx:1977
Int_t GetN() const
Definition TGraph.h:132
Double_t * GetX() const
Definition TGraph.h:139
void SetName(const char *name="") override
Set graph name.
Definition TGraph.cxx:2381
TAxis * GetXaxis() const
Get x axis of the graph.
Definition TGraph.cxx:1566
TAxis * GetYaxis() const
Get y axis of the graph.
Definition TGraph.cxx:1575
void SetTitle(const char *title="") override
Change (i.e.
Definition TGraph.cxx:2397
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px,py to a graph.
Definition TGraph.cxx:879
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px,py to a line.
Definition TLine.cxx:89
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:164
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:48
An array of TObjects.
Definition TObjArray.h:31
Int_t GetEntries() const override
Return the number of objects in array (i.e.
TObject * At(Int_t idx) const override
Definition TObjArray.h:164
TObject * UncheckedAt(Int_t i) const
Definition TObjArray.h:84
Mother of all ROOT objects.
Definition TObject.h:41
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:456
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:199
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition TObject.cxx:202
virtual void SetUniqueID(UInt_t uid)
Set the unique object id.
Definition TObject.cxx:809
@ kCanDelete
if object in a list can be deleted
Definition TObject.h:62
A Pave (see TPave) with text, lines or/and boxes inside.
Definition TPaveText.h:21
virtual TText * AddText(Double_t x1, Double_t y1, const char *label)
Add a new Text line to this pavetext at given coordinates.
void Paint(Option_t *option="") override
Paint this pavetext with its current attributes.
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px,py to a pave.
Definition TPave.cxx:208
Stopwatch class.
Definition TStopwatch.h:28
Double_t RealTime()
Stop the stopwatch (if it is running) and return the realtime (in seconds) passed between the start a...
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
Double_t CpuTime()
Stop the stopwatch (if it is running) and return the cputime (in seconds) passed between the start an...
Basic string class.
Definition TString.h:139
void ToLower()
Change string to lower-case.
Definition TString.cxx:1182
const char * Data() const
Definition TString.h:376
void Resize(Ssiz_t n)
Resize the string. Truncate or add blanks as necessary.
Definition TString.cxx:1152
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2378
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:632
virtual TString GetFromPipe(const char *command)
Execute command and return output in TString.
Definition TSystem.cxx:680
Base class for several text objects.
Definition TText.h:22
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px,py to a string.
Definition TText.cxx:144
void Paint(Option_t *option="") override
Paint this text with its current attributes.
Definition TText.cxx:687
virtual void SetNDC(Bool_t isNDC=kTRUE)
Set NDC mode on if isNDC = kTRUE, off otherwise.
Definition TText.cxx:823
The TTimeStamp encapsulates seconds and ns since EPOCH.
Definition TTimeStamp.h:45
A cache to speed-up the reading of ROOT datasets.
Definition TTreeCache.h:32
const TObjArray * GetCachedBranches() const
Definition TTreeCache.h:139
TTree I/O performance measurement.
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.
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.
static TClass * Class()
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.
std::vector< std::pair< TBranch *, std::vector< size_t > > > BasketList_t
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.
Definition TTree.h:79
TFile * GetCurrentFile() const
Return pointer to the current file.
Definition TTree.cxx:5479
TDirectory * GetDirectory() const
Definition TTree.h:462
virtual Long64_t GetReadEntry() const
Definition TTree.h:549
virtual TTree * GetTree() const
Definition TTree.h:557
TClass * IsA() const override
Definition TTree.h:705
virtual Long64_t GetCacheSize() const
Definition TTree.h:453
Provides the interface for the PROOF internal performance measurement and event tracing.
T MaxElement(Long64_t n, const T *a)
Returns maximum of array a of length n.
Definition TMath.h:968
th1 Draw()