Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TProofProgressStatus.cxx
Go to the documentation of this file.
1 // @(#)root/proof:$Id$
2 // Author: Jan Iwaszkiewicz 08/08/08
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2008, 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 TProofProgressStatus
13 \ingroup proofkernel
14 
15 Container class for processing statistics
16 
17 */
18 
19 #include "TProofProgressStatus.h"
20 #include "TObject.h"
21 #include "TString.h"
22 #include "TSystem.h"
23 #include "TTime.h"
24 
25 ClassImp(TProofProgressStatus);
26 
27 ////////////////////////////////////////////////////////////////////////////////
28 /// Main and default constructor
29 
30 TProofProgressStatus::TProofProgressStatus(Long64_t entries,
31  Long64_t bytesRead,
32  Long64_t readCalls,
33  Double_t procTime,
34  Double_t cpuTime): TObject()
35 {
36  fLastEntries = 0;
37  fEntries = entries;
38  fBytesRead = bytesRead;
39  fReadCalls = readCalls;
40  fLearnTime = 0.;
41  fLastProcTime = 0;
42  fProcTime = procTime;
43  fCPUTime = cpuTime;
44  SetLastUpdate();
45 }
46 
47 ////////////////////////////////////////////////////////////////////////////////
48 /// '+=' operator
49 
50 TProofProgressStatus& TProofProgressStatus::operator+=(const TProofProgressStatus &st)
51 {
52  fLastEntries += st.fEntries;
53  fEntries += st.fEntries;
54  fBytesRead += st.fBytesRead;
55  fReadCalls += st.fReadCalls;
56  if (st.fLearnTime > fLearnTime)
57  fLearnTime = st.fLearnTime;
58  fLastProcTime = st.fProcTime;
59  fProcTime += st.fProcTime;
60  fCPUTime += st.fCPUTime;
61  SetLastUpdate();
62  return *this;
63 }
64 
65 ////////////////////////////////////////////////////////////////////////////////
66 /// '-=' operator
67 
68 TProofProgressStatus& TProofProgressStatus::operator-=(const TProofProgressStatus &st)
69 {
70  fEntries -= st.fEntries;
71  fBytesRead -= st.fBytesRead;
72  fReadCalls -= st.fReadCalls;
73  if (st.fLearnTime < fLearnTime)
74  fLearnTime = st.fLearnTime;
75  fProcTime -= st.fProcTime;
76  fCPUTime -= st.fCPUTime;
77  SetLastUpdate();
78  return *this;
79 }
80 
81 ////////////////////////////////////////////////////////////////////////////////
82 /// '-' operator
83 
84 TProofProgressStatus TProofProgressStatus::operator-(TProofProgressStatus &st)
85 {
86  return TProofProgressStatus(*this) -= st;
87 }
88 
89 ////////////////////////////////////////////////////////////////////////////////
90 /// Dump the content
91 
92 void TProofProgressStatus::Print(Option_t*option) const
93 {
94  Printf("TProofProgressStatus:%s: Ents:(%lld,%lld), Bytes:%lld, Calls:%lld,"
95  " Learn:%.3g s, Proc:(%.3g,%.3g) s, CPU:%.3g s",
96  option, fEntries, fLastEntries, fBytesRead, fReadCalls,
97  fLearnTime, fProcTime, fLastProcTime, fCPUTime);
98 }
99 
100 ////////////////////////////////////////////////////////////////////////////////
101 /// Update time stamp either with the passed value (if > 0) or with
102 /// the current time
103 
104 void TProofProgressStatus::SetLastUpdate(Double_t updtTime)
105 {
106  if (updtTime > 0) {
107  fLastUpdate = updtTime;
108  } else {
109  TTime tnow = gSystem->Now();
110  fLastUpdate = (Double_t) (Long64_t(tnow)) / (Double_t)1000.;
111  }
112 }
113 
114 ////////////////////////////////////////////////////////////////////////////////
115 /// Get current rate. Rteunr the average rate if the current is not defined
116 
117 Double_t TProofProgressStatus::GetCurrentRate() const
118 {
119  if (fLastProcTime > 0) {
120  return fLastEntries / fLastProcTime;
121  }
122  return GetRate();
123 }