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
34namespace itpp
35{
36
45class ITPP_EXPORT Timer
46{
47public:
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
67protected:
69 virtual double get_current_time() const = 0;
71 double start_time;
73 double stop_time;
77 bool running;
78};
79
104class ITPP_EXPORT CPU_Timer : public Timer
105{
106public:
109
110protected:
112 double get_current_time() const;
113};
114
138class ITPP_EXPORT Real_Timer : public Timer
139{
140public:
143
144protected:
146 double get_current_time() const;
147};
148
153ITPP_EXPORT void tic();
154
159ITPP_EXPORT double toc();
160
165ITPP_EXPORT void toc_print();
166
175ITPP_EXPORT void pause(double t = -1);
176
177} // namespace itpp
178
179#endif // #ifndef TIMING_H
A CPU time timer class.
Definition timing.h:105
CPU_Timer()
Create a new timer. Sets the time to zero.
Definition timing.h:108
A real time timer class.
Definition timing.h:139
Real_Timer()
Create a new timer. Sets the time to zero.
Definition timing.h:142
A virtual base class for timers.
Definition timing.h:46
double start_time
The start time of the timer.
Definition timing.h:71
virtual ~Timer()
Virtual destructor.
Definition timing.h:51
bool running
A bool that indicates if the timer is running or not.
Definition timing.h:77
double elapsed_time
The ellapsed time from start to stop.
Definition timing.h:75
virtual double get_current_time() const =0
Vitrual function that returns teh current time.
double stop_time
The stop time of the timer.
Definition timing.h:73
void pause(double t)
pause
Definition timing.cpp:169
void toc_print()
Prints the elapsed time since last tic()
Definition timing.cpp:164
void tic()
Reset and start timer.
Definition timing.cpp:154
double toc()
Returns the elapsed time since last tic()
Definition timing.cpp:159
itpp namespace
Definition itmex.h:37
SourceForge Logo

Generated on Mon Apr 7 2025 07:53:18 for IT++ by Doxygen 1.11.0