ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TestTimer.h
Go to the documentation of this file.
1 #ifndef TESTTIMER_H
2 #define TESTTIMER_H
3 
4 // simple class to measure time
5 
6 #include "TStopwatch.h"
7 
8 
9 namespace ROOT {
10 
11  namespace Math{
12 
13  namespace test {
14 
15 #ifdef REPORT_TIME
16  void reportTime( std::string s, double time);
17 #endif
18 
19  void printTime(TStopwatch & time, std::string s) {
20  int pr = std::cout.precision(8);
21  std::cout << s << "\t" << " time = " << time.RealTime() << "\t(sec)\t"
22  // << time.CpuTime()
23  << std::endl;
24  std::cout.precision(pr);
25  }
26 
27 
28 
29  class Timer {
30 
31  public:
32 
33  Timer(const std::string & s = "") : fName(s), fTime(0)
34  {
35  fWatch.Start();
36  }
37  Timer(double & t, const std::string & s = "") : fName(s), fTime(&t)
38  {
39  fWatch.Start();
40  }
41 
42  ~Timer() {
43  fWatch.Stop();
45 #ifdef REPORT_TIME
46  // report time
47  reportTime(fName, fWatch.RealTime() );
48 #endif
49  if (fTime) *fTime += fWatch.RealTime();
50  }
51 
52 
53  private:
54 
55  std::string fName;
56  double * fTime;
58 
59  };
60  }
61 
62  }
63 }
64 
65 #endif
Double_t RealTime()
Stop the stopwatch (if it is running) and return the realtime (in seconds) passed between the start a...
Definition: TStopwatch.cxx:108
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
Definition: TStopwatch.cxx:56
Timer(double &t, const std::string &s="")
Definition: TestTimer.h:37
void Stop()
Stop the stopwatch.
Definition: TStopwatch.cxx:75
TThread * t[5]
Definition: threadsh1.C:13
void printTime(TStopwatch &time, std::string s)
Definition: TestTimer.h:19
RooCmdArg Timer(Bool_t flag=kTRUE)
Timer(const std::string &s="")
Definition: TestTimer.h:33
Stopwatch class.
Definition: TStopwatch.h:30