74 :
Timer(0, prefix, colourfulOutput)
85 : fNcounts ( ncounts ),
86 fPrefix ( strcmp(prefix,
"")==0?
Timer::fgClassName:
TString(prefix) ),
87 fColourfulOutput( colourfulOutput ),
88 fPreviousProgress(-1),
89 fOutputToFile(!isatty(STDERR_FILENO)),
90 fProgressBarStringLength (0),
91 fLogger ( new
MsgLogger( fPrefix.Data() ) )
118 fPreviousProgress = -1;
119 fPreviousTimeEstimate.Clear();
136 return SecToText( ElapsedSeconds(), Scientific );
144 Double_t leftTime = ( icounts <= 0 ? -1 :
145 icounts > fNcounts ? -1 :
148 return SecToText( leftTime,
kFALSE );
156 fProgressBarStringLength = 0;
159 std::clog << fLogger->GetPrintedSource();
160 std::clog <<
"Please wait ";
163 std::clog <<
"." << std::flush;
172 std::clog << fLogger->GetPrintedSource();
180 for (
int i = fProgressBarStringLength; i < theString.
Length (); ++i)
182 std::clog <<
"\r" << std::flush;
183 fProgressBarStringLength = theString.
Length ();
192 if (!
gConfig().DrawProgressBar())
return;
195 if (icounts > fNcounts-1) icounts = fNcounts-1;
196 if (icounts < 0 ) icounts = 0;
199 auto timeLeft = this->GetLeftTime( icounts );
202 if (ic == fPreviousProgress && timeLeft == fPreviousTimeEstimate && icounts != fNcounts-1)
return;
205 if (ic != fPreviousProgress) {
206 std::clog <<
Int_t((100*(icounts+1))/
Float_t(fNcounts)) <<
"%, time left: " << timeLeft << std::endl;
207 fPreviousProgress = ic;
211 fPreviousProgress = ic;
212 fPreviousTimeEstimate = timeLeft;
214 std::clog << fLogger->GetPrintedSource();
216 else std::clog <<
"[";
217 for (
Int_t i=0; i<ic; i++) {
219 else std::clog <<
">";
221 for (
Int_t i=ic+1; i<fgNbins; i++) {
223 else std::clog <<
".";
226 else std::clog <<
"]" ;
229 if (fColourfulOutput) {
238 std::clog <<
"(" <<
Int_t((100*(icounts+1))/
Float_t(fNcounts)) <<
"%"
239 <<
", " <<
"time left: " << timeLeft <<
") ";
242 std::clog <<
"[" << comment <<
"] ";
244 std::clog <<
"\r" << std::flush;
253 if (Scientific ) out =
Form(
"%.3g sec", seconds );
254 else if (seconds < 0 ) out =
"unknown";
255 else if (seconds <= 300) out =
Form(
"%i sec",
Int_t(seconds) );
257 if (seconds > 3600) {
259 if (
h <= 1) out =
Form(
"%i hr : ",
h );
260 else out =
Form(
"%i hrs : ",
h );
262 seconds =
Int_t(seconds)%3600;
265 if (
m <= 1) out +=
Form(
"%i min",
m );
266 else out +=
Form(
"%i mins",
m );
char * Form(const char *fmt,...)
ostringstream derivative to redirect and format output
Timing information for training and evaluation of MVA methods.
Double_t ElapsedSeconds(void)
computes elapsed tim in seconds
static const Int_t fgNbins
void DrawProgressBar(void)
draws the progressbar
TString SecToText(Double_t, Bool_t) const
pretty string output
TString GetLeftTime(Int_t icounts)
returns pretty string with time left
Timer(const char *prefix="", Bool_t colourfulOutput=kTRUE)
constructor
void Reset(void)
resets timer
virtual ~Timer(void)
destructor
static const TString fgClassName
TString GetElapsedTime(Bool_t Scientific=kTRUE)
returns pretty string with elapsed time
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.