SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Timer.h
Go to the documentation of this file.
1 /*
2  For more information, please see: http://software.sci.utah.edu
3 
4  The MIT License
5 
6  Copyright (c) 2009 Scientific Computing and Imaging Institute,
7  University of Utah.
8 
9 
10  Permission is hereby granted, free of charge, to any person obtaining a
11  copy of this software and associated documentation files (the "Software"),
12  to deal in the Software without restriction, including without limitation
13  the rights to use, copy, modify, merge, publish, distribute, sublicense,
14  and/or sell copies of the Software, and to permit persons to whom the
15  Software is furnished to do so, subject to the following conditions:
16 
17  The above copyright notice and this permission notice shall be included
18  in all copies or substantial portions of the Software.
19 
20  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26  DEALINGS IN THE SOFTWARE.
27 */
28 
29 
30 
31 ///
32 ///@file Timer.h
33 ///@brief Interface to portable timer utility classes
34 ///
35 ///@author
36 /// Steven G. Parker
37 /// Department of Computer Science
38 /// University of Utah
39 ///@date Feb. 1994
40 ///
41 
42 #if !defined(Timer_h)
43 #define Timer_h
44 
46 
47 namespace SCIRun {
48 
49 class SCISHARE Timer {
50 public:
53  Running
54  };
55 
56  Timer();
57  virtual ~Timer();
58 
59  void start();
60  void stop();
61  void clear();
62  double time();
63  void add(double t);
64  timer_state_e state() { return state_; }
65 protected:
66  virtual double get_time() = 0;
67 private:
68  double total_time_;
69  double start_time_;
70  timer_state_e state_;
71 };
72 
73 class SCISHARE CPUTimer : public Timer {
74 public:
75  virtual ~CPUTimer();
76 protected:
77  virtual double get_time();
78 };
79 
80 class SCISHARE WallClockTimer : public Timer {
81 public:
83  virtual ~WallClockTimer();
84 protected:
85  virtual double get_time();
86 };
87 
89 public:
90  TimeThrottle();
91  virtual ~TimeThrottle();
92 
93  void wait_for_time(double time);
94 };
95 
96 } // end namespace SCIRun
97 
98 #endif /* Timer_h */
timer_state_e
Definition: Timer.h:51
Definition: Timer.h:88
#define SCISHARE
Definition: share.h:39
Definition: Timer.h:52
Definition: Timer.h:73
Definition: Timer.h:49
Definition: Timer.h:80
timer_state_e state()
Definition: Timer.h:64