| 
    last update 20 Sep 2009 | 
      | 
   
#include <cvrTimer.h>


Public Types | |
| enum | eTimeType { Wall, Cpu } | 
Public Member Functions | |
| timer () | |
| timer (const eTimeType &timeType) | |
| timer (const timer &other) | |
| virtual | ~timer () | 
| void | start () | 
| void | stop () | 
| double | getTime () const | 
| void | setTimeType (const eTimeType &timeType) | 
| const eTimeType & | getTimeType () | 
| virtual const std::string & | name () const | 
| virtual timer * | clone () const | 
| virtual timer * | newInstance () const | 
Static Public Member Functions | |
| static std::string | getDateAndTime () | 
| static double | getCpuTime () | 
Protected Member Functions | |
| double | getActualTime () const | 
Protected Attributes | |
| eTimeType | timeType_ | 
| double | startTime_ | 
| double | endTime_ | 
| bool | started_ | 
It seems like the precision for CPU time is 1ms on Windows systems. The elapsed time is returned in microseconds.
Depending on the eTimeType (setTimeType()) The CPU time (Cpu) or wall-clock time (Wall) are measured. The default is Cpu.
The maximum time that can be measured with this function in Wall mode is 1 day (86.4E+09 microseconds). To measure longer time intervalls use the standard time() function.
Example:
cvr::timer chron; chron.start(); // do something chron.stop(); std::cout << "something takes " << chron.getTime() << " microseconds\n";
| cvr::timer::timer | ( | ) | 
Default constructor.
| cvr::timer::timer | ( | const eTimeType & | timeType | ) | 
Constructor to set the time type.
| cvr::timer::timer | ( | const timer & | other | ) | 
Copy constructor.
| virtual cvr::timer::~timer | ( | ) |  [virtual] | 
        
Destructor.
| virtual timer* cvr::timer::clone | ( | ) |  const [virtual] | 
        
| double cvr::timer::getActualTime | ( | ) |  const [protected] | 
        
Get actual time.
The implementation of this method depends on the OS.
| static double cvr::timer::getCpuTime | ( | ) |  [static] | 
        
| static std::string cvr::timer::getDateAndTime | ( | ) |  [static] | 
        
Return a string containing the current time.
Obviously this always uses the Wall time.
The format is the one return by the libc function ctime, for example 
Sat Jul 24 22:46:18 CEST 2004
| double cvr::timer::getTime | ( | ) | const | 
| const eTimeType& cvr::timer::getTimeType | ( | ) | 
Returns the current time type.
| virtual const std::string& cvr::timer::name | ( | ) |  const [virtual] | 
        
| virtual timer* cvr::timer::newInstance | ( | ) |  const [virtual] | 
        
| void cvr::timer::setTimeType | ( | const eTimeType & | timeType | ) | 
Sets the time type.
| timeType | the new eTimeType | 
| void cvr::timer::start | ( | ) | 
Start the timer.
| void cvr::timer::stop | ( | ) | 
Stop the timer.
double cvr::timer::endTime_ [protected]           | 
        
Time at which stop() was called.
bool cvr::timer::started_ [protected]           | 
        
double cvr::timer::startTime_ [protected]           | 
        
Time at which start() was called.
eTimeType cvr::timer::timeType_ [protected]           | 
        
Time type used.