ROOT  6.06/09
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 #ifndef ROOT_TString
43 #include "TString.h"
44 #endif
45 #ifndef ROOT_TStopwatch
46 #include "TStopwatch.h"
47 #endif
48 
49 // ensure that clock_t is always defined
50 #if defined(__SUNPRO_CC) && defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 == 500 )
51 #ifndef _CLOCK_T
52 #define _CLOCK_T
53 typedef long clock_t; // relative time in a specified resolution
54 #endif /* ifndef _CLOCK_T */
55 
56 #endif // SUN and XOPENSOURCE=500
57 
58 namespace TMVA {
59 
60  class MsgLogger;
61 
62  class Timer : public TStopwatch {
63 
64  public:
65 
66  Timer( const char* prefix = "", Bool_t colourfulOutput = kTRUE );
67  Timer( Int_t ncounts, const char* prefix = "", Bool_t colourfulOutput = kTRUE );
68  virtual ~Timer( void );
69 
70  void Init ( Int_t ncounts );
71  void Reset( void );
72 
73  // when the "Scientific" flag set, time is returned with subdecimals
74  // for algorithm timing measurement
75  TString GetElapsedTime ( Bool_t Scientific = kTRUE );
76  Double_t ElapsedSeconds ( void );
77  TString GetLeftTime ( Int_t icounts );
78  void DrawProgressBar( Int_t, const TString& comment = "" );
79  void DrawProgressBar( TString );
80  void DrawProgressBar( void );
81 
82  private:
83 
84  TString SecToText ( Double_t, Bool_t ) const;
85 
86  Int_t fNcounts; // reference number of "counts"
87  TString fPrefix; // prefix for outputs
88  Bool_t fColourfulOutput; // flag for use of colors
89 
90  static const TString fgClassName; // used for output
91  static const Int_t fgNbins; // number of bins in progress bar
92 
93  mutable MsgLogger* fLogger; // the output logger
94  MsgLogger& Log() const { return *fLogger; }
95 
96  ClassDef(Timer,0) // Timing information for training and evaluation of MVA methods
97  };
98 
99 } // namespace
100 
101 #endif
void DrawProgressBar(void)
draws the progressbar
Definition: Timer.cxx:152
static const std::string comment("comment")
TString GetLeftTime(Int_t icounts)
returns pretty string with time left
Definition: Timer.cxx:140
void Init(Int_t ncounts)
Definition: Timer.cxx:106
void Reset(void)
resets timer
Definition: Timer.cxx:116
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Bool_t fColourfulOutput
Definition: Timer.h:88
MsgLogger * fLogger
Definition: Timer.h:93
virtual ~Timer(void)
destructor
Definition: Timer.cxx:101
#define ClassDef(name, id)
Definition: Rtypes.h:254
TString GetElapsedTime(Bool_t Scientific=kTRUE)
Definition: Timer.cxx:131
TString fPrefix
Definition: Timer.h:87
static const Int_t fgNbins
Definition: Timer.h:91
Timer(const char *prefix="", Bool_t colourfulOutput=kTRUE)
TString SecToText(Double_t, Bool_t) const
pretty string output
Definition: Timer.cxx:228
Double_t ElapsedSeconds(void)
computes elapsed tim in seconds
Definition: Timer.cxx:124
MsgLogger & Log() const
Definition: Timer.h:94
double Double_t
Definition: RtypesCore.h:55
Int_t fNcounts
Definition: Timer.h:86
Abstract ClassifierFactory template that handles arbitrary types.
static const TString fgClassName
Definition: Timer.h:90
const Bool_t kTRUE
Definition: Rtypes.h:91
Stopwatch class.
Definition: TStopwatch.h:30