ROOT logo
// @(#)root/tmva $Id: Timer.h 29122 2009-06-22 06:51:30Z brun $    
// Author: Andreas Hoecker, Joerg Stelzer, Helge Voss

/**********************************************************************************
 * Project: TMVA - a Root-integrated toolkit for multivariate data analysis       *
 * Package: TMVA                                                                  *
 * Class  : Timer                                                                 *
 * Web    : http://tmva.sourceforge.net                                           *
 *                                                                                *
 * Description:                                                                   *
 *      Timing information for methods training                                   *
 *                                                                                *
 * Authors (alphabetical):                                                        *
 *      Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland              *
 *      Joerg Stelzer   <Joerg.Stelzer@cern.ch>  - CERN, Switzerland              *
 *      Helge Voss      <Helge.Voss@cern.ch>     - MPI-K Heidelberg, Germany      *
 *      Kai Voss        <Kai.Voss@cern.ch>       - U. of Victoria, Canada         *
 *                                                                                *
 * Copyright (c) 2006:                                                            *
 *      CERN, Switzerland                                                         * 
 *      MPI-K Heidelberg, Germany                                                 * 
 *                                                                                *
 * Redistribution and use in source and binary forms, with or without             *
 * modification, are permitted according to the terms listed in LICENSE           *
 * (http://tmva.sourceforge.net/LICENSE)                                          *
 **********************************************************************************/

#ifndef ROOT_TMVA_Timer
#define ROOT_TMVA_Timer

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// Timer                                                                //
//                                                                      //
// Timing information for training and evaluation of MVA methods        //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_time
#include "time.h"
#endif
#ifndef ROOT_TString
#include "TString.h"
#endif
#ifndef ROOT_TStopwatch
#include "TStopwatch.h"
#endif

// ensure that clock_t is always defined
#if defined(__SUNPRO_CC) && defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 == 500 )
#ifndef _CLOCK_T
#define _CLOCK_T
typedef long clock_t; // relative time in a specified resolution
#endif /* ifndef _CLOCK_T */

#endif // SUN and XOPENSOURCE=500

namespace TMVA {

   class MsgLogger;

   class Timer : public TStopwatch {
  
   public:
  
      Timer( const char* prefix = "", Bool_t colourfulOutput = kTRUE );
      Timer( Int_t ncounts, const char* prefix = "", Bool_t colourfulOutput = kTRUE );
      virtual ~Timer( void );
  
      void Init ( Int_t ncounts );
      void Reset( void );

      // when the "Scientific" flag set, time is returned with subdecimals
      // for algorithm timing measurement
      TString   GetElapsedTime ( Bool_t Scientific = kTRUE  );
      Double_t  ElapsedSeconds ( void );
      TString   GetLeftTime     ( Int_t icounts );
      void      DrawProgressBar( Int_t );
      void      DrawProgressBar( TString );
      void      DrawProgressBar( void );
                          
   private:

      TString   SecToText     ( Double_t, Bool_t ) const;

      Int_t     fNcounts;               // reference number of "counts" 
      TString   fPrefix;                // prefix for outputs
      Bool_t    fColourfulOutput;       // flag for use of colors

      static const TString fgClassName; // used for output
      static const Int_t   fgNbins;     // number of bins in progress bar

      mutable MsgLogger*   fLogger;     // the output logger
      MsgLogger& log() const { return *fLogger; }                       

      ClassDef(Timer,0) // Timing information for training and evaluation of MVA methods
   };

} // namespace

#endif
 Timer.h:1
 Timer.h:2
 Timer.h:3
 Timer.h:4
 Timer.h:5
 Timer.h:6
 Timer.h:7
 Timer.h:8
 Timer.h:9
 Timer.h:10
 Timer.h:11
 Timer.h:12
 Timer.h:13
 Timer.h:14
 Timer.h:15
 Timer.h:16
 Timer.h:17
 Timer.h:18
 Timer.h:19
 Timer.h:20
 Timer.h:21
 Timer.h:22
 Timer.h:23
 Timer.h:24
 Timer.h:25
 Timer.h:26
 Timer.h:27
 Timer.h:28
 Timer.h:29
 Timer.h:30
 Timer.h:31
 Timer.h:32
 Timer.h:33
 Timer.h:34
 Timer.h:35
 Timer.h:36
 Timer.h:37
 Timer.h:38
 Timer.h:39
 Timer.h:40
 Timer.h:41
 Timer.h:42
 Timer.h:43
 Timer.h:44
 Timer.h:45
 Timer.h:46
 Timer.h:47
 Timer.h:48
 Timer.h:49
 Timer.h:50
 Timer.h:51
 Timer.h:52
 Timer.h:53
 Timer.h:54
 Timer.h:55
 Timer.h:56
 Timer.h:57
 Timer.h:58
 Timer.h:59
 Timer.h:60
 Timer.h:61
 Timer.h:62
 Timer.h:63
 Timer.h:64
 Timer.h:65
 Timer.h:66
 Timer.h:67
 Timer.h:68
 Timer.h:69
 Timer.h:70
 Timer.h:71
 Timer.h:72
 Timer.h:73
 Timer.h:74
 Timer.h:75
 Timer.h:76
 Timer.h:77
 Timer.h:78
 Timer.h:79
 Timer.h:80
 Timer.h:81
 Timer.h:82
 Timer.h:83
 Timer.h:84
 Timer.h:85
 Timer.h:86
 Timer.h:87
 Timer.h:88
 Timer.h:89
 Timer.h:90
 Timer.h:91
 Timer.h:92
 Timer.h:93
 Timer.h:94
 Timer.h:95
 Timer.h:96
 Timer.h:97
 Timer.h:98
 Timer.h:99
 Timer.h:100
 Timer.h:101