EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FairDbTimer.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FairDbTimer.cxx
1 
2 #include "FairDbTimer.h"
3 
5 
7  fCurSubWatch(0),
8  fRowSize(0),
9  fQueryStage(kPassive),
10  fSubWatches(),
11  fTableName(),
12  fWatch()
13 {
14  fWatch.Stop();
15  for ( int subWatch = 0; subWatch < kMaxSubWatch; ++subWatch) {
16  fSubWatches[subWatch].Stop();
17  }
18 
19 }
20 
21 
23 {
24 
25 }
26 
27 
28 void FairDbTimer::RecBegin(string tableName, UInt_t rowSize)
29 {
30 
32  fTableName = tableName;
33  fRowSize = rowSize;
34  fWatch.Start();
35  for ( int subWatch = 0; subWatch < kMaxSubWatch; ++subWatch) {
36  // Use Start to reset the counter (Reset doesn't do this).
37  fSubWatches[subWatch].Start();
38  fSubWatches[subWatch].Stop();
39  }
40  if ( fCurSubWatch >= 0 ) { this->StartSubWatch(0); }
41 
42 }
43 
44 void FairDbTimer::RecEnd(UInt_t numRows)
45 {
46 
47  if ( fQueryStage != kMainQuery ) { return; }
48 
49  Float_t tableSize = numRows * fRowSize/1.0e+3;
50  string units = "Kb";
51  if ( tableSize > 1000. ) {
52  tableSize /= 1000.;
53  units = "Mb";
54  }
55 
56  cout << "FairDbTimer:" << fTableName
57  << ": Query done. " << numRows
58  << "rows, " << tableSize << units
59  << " Cpu" << fWatch.CpuTime()
60  << " , elapse" << fWatch.RealTime()
61  << endl;
62 
63  fWatch.Stop();
65 
66  if ( fCurSubWatch >= 0 && fWatch.RealTime() > 5. ) {
67  for ( int subWatch = 0; subWatch < kMaxSubWatch; ++subWatch) {
68  static const Char_t* subWatchNames[kMaxSubWatch]
69  = { "Query database ",
70  "Create row objects ",
71  "Retrieve TSQL rows ",
72  "Fill row objects "
73  };
74 
75  cout << " SubWatch " << subWatchNames[subWatch]
76  << ": Cpu" << fSubWatches[subWatch].CpuTime()
77  << " , elapse" << fSubWatches[subWatch].RealTime()
78  << " , Starts " << fSubWatches[subWatch].Counter()
79  << endl;
80  }
81  }
82 }
83 //.....................................................................
84 
86 {
87 
89 
90 }
91 
92 void FairDbTimer::RecFillAgg(Int_t /* aggNo */)
93 {
94 
95 }
96 
98 {
99 
100  if ( fCurSubWatch >= 0 ) { fSubWatches[fCurSubWatch].Start(kFALSE); }
101  fWatch.Start(kFALSE);
102 }
103 
104 
105 void FairDbTimer::StartSubWatch(UInt_t subWatch)
106 {
107 
108  if ( fCurSubWatch < 0
109  || subWatch >= kMaxSubWatch ) { return; }
110 
111  fSubWatches[fCurSubWatch].Stop();
112  fCurSubWatch = subWatch;
113  fSubWatches[fCurSubWatch].Start(kFALSE);
114 
115 }
116 
118 {
119 
120  if ( fCurSubWatch >= 0 ) { fSubWatches[fCurSubWatch].Stop(); }
121  fWatch.Stop();
122 }
123