itpp::Real_Timer Class Reference
Base Module » Timers

A real time timer class. More...

`#include <itpp/base/timing.h>`

Inheritance diagram for itpp::Real_Timer:

## Public Member Functions

| Real_Timer ()
| Create a new timer. Sets the time to zero.
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

double | get_current_time () const
| 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 real time timer class.

Measures real time.

Usage: Define a time object:

Real_Timer timer;
itpp::Real_Timer
A real time timer class.
Definition timing.h:139

Actions: Reset:

timer.reset();
itpp::Timer::reset
void reset(double t=0.0)
Sets the time to time t, which is zero by default. Stops the timer if it is running.
Definition timing.cpp:104

Start:

timer.start();
itpp::Timer::start
void start(void)
Start the timer. This does not set the time to zero.
Definition timing.cpp:85

Stop:

timer.stop();
itpp::Timer::stop
double stop(void)
Stop the timer. Returns the elapsed time in seconds.
Definition timing.cpp:93

Get time:

elapsedtime = timer.get_time();
itpp::Array
General array class.
Definition array.h:105
itpp::Timer::get_time
double get_time() const
Returns the elapsed time.
Definition timing.cpp:112

It is possible to get elapsed time without stopping the timer. Observe that it is also possible to use the macros "time.tic();" to reset and start clock and "time.toc_print();" to print the elapsed time.

Warning
  May give an negative answer if the measured time is too long.

Definition at line 138 of file timing.h.

## Constructor & Destructor Documentation

## Real_Timer()

itpp::Real_Timer::Real_Timer | ( |  | ) |

inline

Create a new timer. Sets the time to zero.

Definition at line 142 of file timing.h.

## Member Function Documentation

## get_current_time()

double itpp::Real_Timer::get_current_time | ( |  | ) | const

protected virtual

Vitrual function that returns teh current time.

Implements itpp::Timer.

Definition at line 146 of file timing.cpp.

## start()

void itpp::Timer::start | ( | void |  | ) |

inherited

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

Definition at line 85 of file timing.cpp.

References itpp::Timer::get_current_time(), itpp::Timer::running, and itpp::Timer::start_time.

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

## stop()

double itpp::Timer::stop | ( | void |  | ) |

inherited

Stop the timer. Returns the elapsed time in seconds.

Definition at line 93 of file timing.cpp.

References itpp::Timer::elapsed_time, itpp::Timer::get_current_time(), itpp::Timer::running, itpp::Timer::start_time, and itpp::Timer::stop_time.

## reset()

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

inherited

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 itpp::Timer::elapsed_time, itpp::Timer::running, itpp::Timer::start_time, and itpp::Timer::stop_time.

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

## tic()

void itpp::Timer::tic | ( | void |  | ) |

inherited

Resets the timer and starts it.

Definition at line 119 of file timing.cpp.

References itpp::Timer::reset(), and itpp::Timer::start().

Referenced by itpp::tic().

## toc()

double itpp::Timer::toc | ( | void |  | ) |

inherited

Returns the elapsed time since last tic()

Definition at line 125 of file timing.cpp.

References itpp::Timer::get_time().

Referenced by itpp::toc().

## toc_print()

void itpp::Timer::toc_print | ( | void |  | ) |

inherited

Prints the elapsed time since last tic()

Definition at line 130 of file timing.cpp.

References itpp::Timer::get_time().

Referenced by itpp::toc_print().

## get_time()

double itpp::Timer::get_time | ( |  | ) | const

inherited

Returns the elapsed time.

Definition at line 112 of file timing.cpp.

References itpp::Timer::elapsed_time, itpp::Timer::get_current_time(), itpp::Timer::running, and itpp::Timer::start_time.

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

## Member Data Documentation

## start_time

double itpp::Timer::start_time

protected inherited

The start time of the timer.

Definition at line 71 of file timing.h.

Referenced by itpp::Timer::get_time(), itpp::Timer::reset(), itpp::Timer::start(), and itpp::Timer::stop().

## stop_time

double itpp::Timer::stop_time

protected inherited

The stop time of the timer.

Definition at line 73 of file timing.h.

Referenced by itpp::Timer::reset(), and itpp::Timer::stop().

## elapsed_time

double itpp::Timer::elapsed_time

protected inherited

The ellapsed time from start to stop.

Definition at line 75 of file timing.h.

Referenced by itpp::Timer::get_time(), itpp::Timer::reset(), and itpp::Timer::stop().

## running

bool itpp::Timer::running

protected inherited

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

Definition at line 77 of file timing.h.

Referenced by itpp::Timer::get_time(), itpp::Timer::reset(), itpp::Timer::start(), and itpp::Timer::stop().

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

- itpp/base/timing.h
- itpp/base/timing.cpp

Generated on Mon Apr 22 2024 09:45:27 for IT++ by Doxygen 1.9.8