IT++ Logo
timing.h
Go to the documentation of this file.
1 
29 #ifndef TIMING_H
30 #define TIMING_H
31 
32 #include <itpp/itexports.h>
33 
34 namespace itpp
35 {
36 
45 class ITPP_EXPORT Timer
46 {
47 public:
49  Timer();
51  virtual ~Timer() { }
53  void start(void);
55  double stop(void);
57  void reset(double t = 0.0);
59  void tic(void);
61  double toc(void);
63  void toc_print(void);
65  double get_time() const;
66 
67 protected:
69  virtual double get_current_time() const = 0;
71  double start_time;
73  double stop_time;
75  double elapsed_time;
77  bool running;
78 };
79 
104 class ITPP_EXPORT CPU_Timer : public Timer
105 {
106 public:
108  CPU_Timer() { }
109 
110 protected:
112  double get_current_time() const;
113 };
114 
138 class ITPP_EXPORT Real_Timer : public Timer
139 {
140 public:
143 
144 protected:
146  double get_current_time() const;
147 };
148 
153 ITPP_EXPORT void tic();
154 
159 ITPP_EXPORT double toc();
160 
165 ITPP_EXPORT void toc_print();
166 
175 ITPP_EXPORT void pause(double t = -1);
176 
177 } // namespace itpp
178 
179 #endif // #ifndef TIMING_H
itpp::Timer::start_time
double start_time
The start time of the timer.
Definition: timing.h:71
itpp::Timer::~Timer
virtual ~Timer()
Virtual destructor.
Definition: timing.h:51
itpp::toc
double toc()
Returns the elapsed time since last tic()
Definition: timing.cpp:159
itpp::Timer::elapsed_time
double elapsed_time
The ellapsed time from start to stop.
Definition: timing.h:75
itpp::Timer::running
bool running
A bool that indicates if the timer is running or not.
Definition: timing.h:77
itpp::Real_Timer::Real_Timer
Real_Timer()
Create a new timer. Sets the time to zero.
Definition: timing.h:142
itpp
itpp namespace
Definition: itmex.h:36
itpp::Real_Timer
A real time timer class.
Definition: timing.h:138
itpp::CPU_Timer
A CPU time timer class.
Definition: timing.h:104
itpp::toc_print
void toc_print()
Prints the elapsed time since last tic()
Definition: timing.cpp:164
itpp::Timer
A virtual base class for timers.
Definition: timing.h:45
itpp::pause
void pause(double t)
pause
Definition: timing.cpp:169
itpp::tic
void tic()
Reset and start timer.
Definition: timing.cpp:154
itpp::Timer::stop_time
double stop_time
The stop time of the timer.
Definition: timing.h:73
itpp::CPU_Timer::CPU_Timer
CPU_Timer()
Create a new timer. Sets the time to zero.
Definition: timing.h:108
SourceForge Logo

Generated on Sat Jun 22 2019 19:10:12 for IT++ by Doxygen 1.8.17