IT++ Logo
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
itpp::CPU_Timer Class Reference

A CPU time timer classMeasures the time spent by the CPU on the current process. If two processes are running concurrently, one real seconds equal 5 CPU seconds per process. The resolution is not very good (in the order of 0.01 seconds). More...

#include <itpp/base/timing.h>

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

Public Member Functions

 CPU_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 CPU time timer class

Measures the time spent by the CPU on the current process. If two processes are running concurrently, one real seconds equal 5 CPU seconds per process. The resolution is not very good (in the order of 0.01 seconds).

Usage: Define a time object:

CPU_Timer timer;

Actions: Reset:

timer.reset();

Start:

timer.start();

Stop:

timer.stop();

Get time:

elapsedtime = timer.get_time();

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();" stop and print the elapsed time.

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

Definition at line 104 of file timing.h.


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

Generated on Sat Jul 6 2013 10:54:31 for IT++ by Doxygen 1.8.2