Logo ROOT  
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 
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
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TMVA::Timer::fPreviousProgress
Int_t fPreviousProgress
Definition: Timer.h:109
TMVA::Timer::Reset
void Reset(void)
resets timer
Definition: Timer.cxx:127
TMVA::Timer::fLogger
MsgLogger * fLogger
Definition: Timer.h:118
TMVA::Timer::fProgressBarStringLength
Int_t fProgressBarStringLength
Definition: Timer.h:113
TStopwatch.h
TMVA::Timer::fNcounts
Int_t fNcounts
Definition: Timer.h:104
Int_t
int Int_t
Definition: RtypesCore.h:45
TString
Definition: TString.h:136
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TString.h
bool
TMVA::Timer::ElapsedSeconds
Double_t ElapsedSeconds(void)
computes elapsed tim in seconds
Definition: Timer.cxx:137
TMVA::Timer::fgNbins
static const Int_t fgNbins
Definition: Timer.h:116
TMVA::Timer::GetElapsedTime
TString GetElapsedTime(Bool_t Scientific=kTRUE)
returns pretty string with elapsed time
Definition: Timer.cxx:146
TMVA::Timer::fPrefix
TString fPrefix
Definition: Timer.h:105
TMVA::Timer::Log
MsgLogger & Log() const
Definition: Timer.h:119
TMVA::Timer::~Timer
virtual ~Timer(void)
destructor
Definition: Timer.cxx:112
TMVA::Timer::SecToText
TString SecToText(Double_t, Bool_t) const
pretty string output
Definition: Timer.cxx:262
TMVA::Timer::Init
void Init(Int_t ncounts)
Definition: Timer.cxx:117
TMVA::Timer
Definition: Timer.h:80
Double_t
double Double_t
Definition: RtypesCore.h:59
TMVA::MsgLogger
Definition: MsgLogger.h:83
TMVA::Timer::GetLeftTime
TString GetLeftTime(Int_t icounts)
returns pretty string with time left
Definition: Timer.cxx:154
TMVA::Timer::fColourfulOutput
Bool_t fColourfulOutput
Definition: Timer.h:106
TStopwatch
Definition: TStopwatch.h:28
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TMVA::Timer::fgClassName
static const TString fgClassName
Definition: Timer.h:115
TMVA::Timer::fPreviousTimeEstimate
TString fPreviousTimeEstimate
Definition: Timer.h:110
TMVA::Timer::fOutputToFile
Bool_t fOutputToFile
Definition: Timer.h:111
TMVA::Timer::Timer
Timer(const char *prefix="", Bool_t colourfulOutput=kTRUE)
constructor
Definition: Timer.cxx:85
ROOT::TMetaUtils::propNames::comment
static const std::string comment("comment")
TMVA
create variable transformations
Definition: GeneticMinimizer.h:22
int
TMVA::Timer::DrawProgressBar
void DrawProgressBar(void)
draws the progressbar
Definition: Timer.cxx:166
RooFit::Timer
RooCmdArg Timer(Bool_t flag=kTRUE)
Definition: RooGlobalFunc.cxx:188