IT++ Logo
itpp::Timer Class Referenceabstract

A virtual base class for timers. More...

#include <itpp/base/timing.h>

Inheritance diagram for itpp::Timer:
itpp::CPU_Timer itpp::Real_Timer

Public Member Functions

 Timer ()
 Create a new timer. Sets the time to zero.
 
virtual ~Timer ()
 Virtual destructor.
 
void start (void)
 Start the timer. This does not set the time to zero.
 
double stop (void)
 Stop the timer. Returns the elapsed time in seconds.
 
void reset (double t=0.0)
 Sets the time to time t, which is zero by default. Stops the timer if it is running.
 
void tic (void)
 Resets the timer and starts it.
 
double toc (void)
 Returns the elapsed time since last tic()
 
void toc_print (void)
 Prints the elapsed time since last tic()
 
double get_time () const
 Returns the elapsed time.
 

Protected Member Functions

virtual double get_current_time () const =0
 Vitrual function that returns teh current time.
 

Protected Attributes

double start_time
 The start time of the timer.
 
double stop_time
 The stop time of the timer.
 
double elapsed_time
 The ellapsed time from start to stop.
 
bool running
 A bool that indicates if the timer is running or not.
 

Detailed Description

A virtual base class for timers.

Definition at line 45 of file timing.h.

Constructor & Destructor Documentation

◆ Timer()

itpp::Timer::Timer ( )

Create a new timer. Sets the time to zero.

Definition at line 80 of file timing.cpp.

References reset().

◆ ~Timer()

virtual itpp::Timer::~Timer ( )
inlinevirtual

Virtual destructor.

Definition at line 51 of file timing.h.

Member Function Documentation

◆ start()

void itpp::Timer::start ( void )

Start the timer. This does not set the time to zero.

Definition at line 85 of file timing.cpp.

References get_current_time(), running, and start_time.

Referenced by itpp::pause(), and tic().

◆ stop()

double itpp::Timer::stop ( void )

Stop the timer. Returns the elapsed time in seconds.

Definition at line 93 of file timing.cpp.

References elapsed_time, get_current_time(), running, start_time, and stop_time.

◆ reset()

void itpp::Timer::reset ( double t = 0.0)

Sets the time to time t, which is zero by default. Stops the timer if it is running.

Definition at line 104 of file timing.cpp.

References elapsed_time, running, start_time, and stop_time.

Referenced by tic(), and Timer().

◆ tic()

void itpp::Timer::tic ( void )

Resets the timer and starts it.

Definition at line 119 of file timing.cpp.

References reset(), and start().

Referenced by itpp::MOG_diag_EM_sup::ml_iterate(), and itpp::tic().

◆ toc()

double itpp::Timer::toc ( void )

Returns the elapsed time since last tic()

Definition at line 125 of file timing.cpp.

References get_time().

Referenced by itpp::MOG_diag_EM_sup::ml_iterate(), and itpp::toc().

◆ toc_print()

void itpp::Timer::toc_print ( void )

Prints the elapsed time since last tic()

Definition at line 130 of file timing.cpp.

References get_time().

Referenced by itpp::toc_print().

◆ get_time()

double itpp::Timer::get_time ( ) const

Returns the elapsed time.

Definition at line 112 of file timing.cpp.

References elapsed_time, get_current_time(), running, and start_time.

Referenced by itpp::pause(), toc(), and toc_print().

◆ get_current_time()

virtual double itpp::Timer::get_current_time ( ) const
protectedpure virtual

Vitrual function that returns teh current time.

Implemented in itpp::CPU_Timer, and itpp::Real_Timer.

Referenced by get_time(), start(), and stop().

Member Data Documentation

◆ start_time

double itpp::Timer::start_time
protected

The start time of the timer.

Definition at line 71 of file timing.h.

Referenced by get_time(), reset(), start(), and stop().

◆ stop_time

double itpp::Timer::stop_time
protected

The stop time of the timer.

Definition at line 73 of file timing.h.

Referenced by reset(), and stop().

◆ elapsed_time

double itpp::Timer::elapsed_time
protected

The ellapsed time from start to stop.

Definition at line 75 of file timing.h.

Referenced by get_time(), reset(), and stop().

◆ running

bool itpp::Timer::running
protected

A bool that indicates if the timer is running or not.

Definition at line 77 of file timing.h.

Referenced by get_time(), reset(), start(), and stop().


The documentation for this class was generated from the following files:
SourceForge Logo

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