]> Creatis software - clitk.git/blob - common/clitkTimer.h
remove MACRO for vvTool and others minors stuffs
[clitk.git] / common / clitkTimer.h
1 #ifndef CLITKTIMER_H
2 #define CLITKTIMER_H
3
4 /**
5    ===================================================================
6    * @file   clitkTimer.h
7    * @author David Sarrut <David.Sarrut@creatis.insa-lyon.fr>
8    * @date   18 Jul 2007 16:26:08
9
10    * @brief  
11
12    ===================================================================*/
13
14 // #ifdef UNIX
15
16 #include "clitkCommon.h"
17 #include <ctime> 
18 #include <sys/time.h>
19 #include <sys/resource.h>
20 #include <iostream>
21 #include <utility>
22
23 namespace clitk {
24
25   class Timer {
26   public:
27     
28     //====================================================================
29     Timer();
30     void Start();
31     void Stop(bool accumulate=true);
32     void Reset();
33     void Print(std::ostream & os=std::cout) const; 
34     void Print(std::string text, std::ostream & os=std::cout) const;
35     //====================================================================
36     
37     //====================================================================
38     long double GetTimeInMicroSecond()     const { return mElapsed; }
39     long double GetMeanTimeInMicroSecond() const { return mElapsed/mNumberOfCall; }
40     long int GetNumberOfCall()             const { return mNumberOfCall; }
41     //====================================================================
42     
43   protected:
44     rusage mBegin; 
45     rusage mEnd;
46     long double mElapsed;
47     long int mNumberOfCall;
48   };
49
50 } // end namespace
51
52 // #endif
53 #endif /* end #define CLITKTIMER_H */
54