Logo ROOT   6.12/07
Reference Guide
Timer.h
Go to the documentation of this file.
1 // @(#)root/tmva $Id$
2 // Author: Andreas Hoecker, Joerg Stelzer, Helge Voss
3 
4 /**********************************************************************************
5  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6  * Package: TMVA *
7  * Class : Timer *
8  * Web : http://tmva.sourceforge.net *
9  * *
10  * Description: *
11  * Timing information for methods training *
12  * *
13  * Authors (alphabetical): *
14  * Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland *
15  * Joerg Stelzer <Joerg.Stelzer@cern.ch> - CERN, Switzerland *
16  * Helge Voss <Helge.Voss@cern.ch> - MPI-K Heidelberg, Germany *
17  * Kai Voss <Kai.Voss@cern.ch> - U. of Victoria, Canada *
18  * *
19  * Copyright (c) 2006: *
20  * CERN, Switzerland *
21  * MPI-K Heidelberg, Germany *
22  * *
23  * Redistribution and use in source and binary forms, with or without *
24  * modification, are permitted according to the terms listed in LICENSE *
25  * (http://tmva.sourceforge.net/LICENSE) *
26  **********************************************************************************/
27 
28 #ifndef ROOT_TMVA_Timer
29 #define ROOT_TMVA_Timer
30 
31 //////////////////////////////////////////////////////////////////////////
32 // //
33 // Timer //
34 // //
35 // Timing information for training and evaluation of MVA methods //
36 // //
37 //////////////////////////////////////////////////////////////////////////
38 
39 #ifndef ROOT_time
40 #include "time.h"
41 #endif
42 #include "TString.h"
43 #include "TStopwatch.h"
44 
45 // ensure that clock_t is always defined
46 #if defined(__SUNPRO_CC) && defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 == 500 )
47 #ifndef _CLOCK_T
48 #define _CLOCK_T
49 typedef long clock_t; // relative time in a specified resolution
50 #endif /* ifndef _CLOCK_T */
51 
52 #endif // SUN and XOPENSOURCE=500
53 
54 namespace TMVA {
55 
56  class MsgLogger;
57 
58  class Timer : public TStopwatch {
59 
60  public:
61 
62  Timer( const char* prefix = "", Bool_t colourfulOutput = kTRUE );
63  Timer( Int_t ncounts, const char* prefix = "", Bool_t colourfulOutput = kTRUE );
64  virtual ~Timer( void );
65 
66  void Init ( Int_t ncounts );
67  void Reset( void );
68 
69  // when the "Scientific" flag set, time is returned with sub-decimals
70  // for algorithm timing measurement
71  TString GetElapsedTime ( Bool_t Scientific = kTRUE );
72  Double_t ElapsedSeconds ( void );
73  TString GetLeftTime ( Int_t icounts );
74  void DrawProgressBar( Int_t, const TString& comment = "" );
75  void DrawProgressBar( TString );
76  void DrawProgressBar( void );
77 
78  private:
79 
80  TString SecToText ( Double_t, Bool_t ) const;
81 
82  Int_t fNcounts; // reference number of "counts"
83  TString fPrefix; // prefix for outputs
84  Bool_t fColourfulOutput; // flag for use of colors
85 
86  // Save state of previos progress
90 
92 
93  static const TString fgClassName; // used for output
94  static const Int_t fgNbins; // number of bins in progress bar
95 
96  mutable MsgLogger* fLogger; // the output logger
97  MsgLogger& Log() const { return *fLogger; }
98 
99  ClassDef(Timer,0); // Timing information for training and evaluation of MVA methods
100  };
101 
102 } // namespace
103 
104 #endif
void DrawProgressBar(void)
draws the progressbar
Definition: Timer.cxx:154
TString fPreviousTimeEstimate
Definition: Timer.h:88
TString GetLeftTime(Int_t icounts)
returns pretty string with time left
Definition: Timer.cxx:142
Int_t fPreviousProgress
Definition: Timer.h:87
void Init(Int_t ncounts)
Definition: Timer.cxx:105
void Reset(void)
resets timer
Definition: Timer.cxx:115
Basic string class.
Definition: TString.h:125
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Bool_t fColourfulOutput
Definition: Timer.h:84
Int_t fProgressBarStringLength
Definition: Timer.h:91
MsgLogger * fLogger
Definition: Timer.h:96
virtual ~Timer(void)
destructor
Definition: Timer.cxx:100
#define ClassDef(name, id)
Definition: Rtypes.h:320
MsgLogger & Log() const
Definition: Timer.h:97
TString GetElapsedTime(Bool_t Scientific=kTRUE)
returns pretty string with elapsed time
Definition: Timer.cxx:134
TString fPrefix
Definition: Timer.h:83
static const Int_t fgNbins
Definition: Timer.h:94
Timer(const char *prefix="", Bool_t colourfulOutput=kTRUE)
constructor
Definition: Timer.cxx:73
Double_t ElapsedSeconds(void)
computes elapsed tim in seconds
Definition: Timer.cxx:125
double Double_t
Definition: RtypesCore.h:55
Int_t fNcounts
Definition: Timer.h:82
ostringstream derivative to redirect and format output
Definition: MsgLogger.h:59
Bool_t fOutputToFile
Definition: Timer.h:89
Abstract ClassifierFactory template that handles arbitrary types.
static const TString fgClassName
Definition: Timer.h:93
TString SecToText(Double_t, Bool_t) const
pretty string output
Definition: Timer.cxx:250
const Bool_t kTRUE
Definition: RtypesCore.h:87
Timing information for training and evaluation of MVA methods.
Definition: Timer.h:58
Stopwatch class.
Definition: TStopwatch.h:28