10 #include <TBenchmark.h>
13 #include <TTreeCache.h>
36 : m_fileMetrics (0), m_jobMetrics (0), m_filesRead (0)
37 , m_eventsRead (0), m_benchmark (0)
47 if (m_benchmark) {
delete m_benchmark; }
55 m_benchmark =
new TBenchmark;
56 m_benchmark->Start(
"loopmetrics");
57 wk()->addOutput (m_fileMetrics =
new TTree (
"EventLoop_Metrics/cacheStats",
58 "TTree cache stats per file"));
59 wk()->addOutput (m_jobMetrics =
new TTree (
"EventLoop_Metrics/jobs",
60 "event throughput per job"));
61 return EL::StatusCode::SUCCESS;
70 return EL::StatusCode::SUCCESS;
81 TTreeCache *tc = (TTreeCache*)wk()->inputFile()->GetCacheRead(wk()->tree());
83 Int_t nBranches = tc->GetCachedBranches()->GetEntries();
84 m_fileMetrics->Branch (
"nBranches", &nBranches,
"nBranches/I");
85 Int_t nLearn = tc->GetLearnEntries();
86 m_fileMetrics->Branch (
"learnEntries", &nLearn,
"learnEntries/I");
87 Double_t
eff = tc->GetEfficiency ();
88 m_fileMetrics->Branch (
"cacheEfficiency", &
eff,
"cacheEfficiency/D");
89 Double_t effRel = tc->GetEfficiencyRel ();
90 m_fileMetrics->Branch (
"cacheEfficiencyRel", &effRel,
"cacheEfficiencyRel/D");
91 Long64_t bytesRead = tc->GetBytesRead ();
92 m_fileMetrics->Branch (
"bytesRead", &bytesRead,
"bytesRead/L");
93 Int_t readCalls = tc->GetReadCalls ();
94 m_fileMetrics->Branch (
"readCalls", &readCalls,
"readCalls/I");
95 Long64_t ncBytesRead = tc->GetNoCacheBytesRead ();
96 m_fileMetrics->Branch (
"noCacheBytesRead", &ncBytesRead,
"noCacheBytesRead/L");
97 Int_t ncReadCalls = tc->GetNoCacheReadCalls ();
98 m_fileMetrics->Branch (
"noCacheReadCalls", &ncReadCalls,
"noCacheReadCalls/I");
99 Int_t readahead = TFile::GetReadaheadSize ();
100 m_fileMetrics->Branch (
"readaheadSize", &readahead,
"readaheadSize/I");
101 Long64_t bytesReadExtra = tc->GetBytesReadExtra ();
102 m_fileMetrics->Branch (
"bytesReadExtra", &bytesReadExtra,
"bytesReadExtra/L");
103 m_fileMetrics->Fill ();
105 return EL::StatusCode::SUCCESS;
114 return EL::StatusCode::SUCCESS;
122 m_benchmark->Stop(
"loopmetrics");
123 m_jobMetrics->Branch(
"eventsRead", &m_eventsRead,
"eventsRead/I");
124 m_jobMetrics->Branch(
"filesRead", &m_filesRead,
"filesRead/I");
125 Float_t realTime = m_benchmark->GetRealTime(
"loopmetrics");
126 m_jobMetrics->Branch(
"loopWallTime", &realTime,
"loopWallTime/F");
127 Float_t cpuTime = m_benchmark->GetCpuTime(
"loopmetrics");
128 m_jobMetrics->Branch(
"loopCpuTime", &cpuTime,
"loopCpuTime/F");
129 Float_t evtsWallSec = m_eventsRead / (realTime != 0 ? realTime : 1.);
130 m_jobMetrics->Branch(
"eventsPerWallSec", &evtsWallSec,
"eventsPerWallSec/F");
131 Float_t evtsCpuSec = m_eventsRead / (cpuTime != 0 ? cpuTime : 1.);
132 m_jobMetrics->Branch(
"eventsPerCpuSec", &evtsCpuSec,
"eventsPerCpuSec/F");
133 m_jobMetrics->Fill();
134 return EL::StatusCode::SUCCESS;