30 # include <itpp/config.h> 32 # include <itpp/config_msvc.h> 35 #ifdef TIME_WITH_SYS_TIME 36 # include <sys/time.h> 39 # ifdef HAVE_SYS_TIME_H 40 # include <sys/time.h> 52 #if defined(_WIN32) && !defined(__CYGWIN__) 55 int gettimeofday(
struct timeval* p,
void*)
62 GetSystemTimeAsFileTime(&(_now.ft));
63 p->tv_usec = (long)((_now.ns100 / 10LL) % 1000000LL);
65 p->tv_sec = (long)((_now.ns100 - 116444736000000000LL) / 10000000LL);
132 std::cout <<
"Elapsed time = " <<
get_time() <<
" seconds" << std::endl;
140 return static_cast<double>(clock()) / CLOCKS_PER_SEC;
150 return t.tv_sec + t.tv_usec * 1.0e-6;
172 std::cout <<
"(Press enter to continue)" << std::endl;
Timer()
Create a new timer. Sets the time to zero.
double get_time() const
Returns the elapsed time.
Real_Timer __tic_toc_timer
Global object for tic and toc functions.
double stop_time
The stop time of the timer.
void start(void)
Start the timer. This does not set the time to zero.
double toc(void)
Returns the elapsed time since last tic()
double get_current_time() const
Vitrual function that returns teh current time.
bool running
A bool that indicates if the timer is running or not.
double stop(void)
Stop the timer. Returns the elapsed time in seconds.
void toc_print()
Prints the elapsed time since last tic()
double start_time
The start time of the timer.
A real time timer classMeasures real time.
double elapsed_time
The ellapsed time from start to stop.
void reset(double t=0.0)
Sets the time to time t, which is zero by default. Stops the timer if it is running.
virtual double get_current_time() const =0
Vitrual function that returns teh current time.
double get_current_time() const
Vitrual function that returns teh current time.
void pause(double t)
pause
void toc_print(void)
Prints the elapsed time since last tic()
void tic()
Reset and start timer.
void tic(void)
Resets the timer and starts it.
Definitions of Timing classes.
double toc()
Returns the elapsed time since last tic()