OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
timer Class Reference

Class for cpu time benchmarking. More...

Detailed Description

Class for cpu time benchmarking.

Usage:

timer t;
// start the timer
t.start();
sleep(1);
// get the elapsed real time and cpu time without stop
BOOST_REQUIRE_CLOSE(t.getwct(),1.0,10.0);
BOOST_REQUIRE_SMALL(t.getcputime(),10.0);
sleep(1);
// stop the timer
t.stop();
sleep(1);
// unusefull
t.stop();
// get the cpu time and real time
t.getwct();
// get the elapsed real time and cpu time without stop
BOOST_REQUIRE_CLOSE(t.getwct(),2.0,10.0);
BOOST_REQUIRE_SMALL(t.getcputime(),10.0);
t.reset();
BOOST_REQUIRE_CLOSE(t.getwct(),0.0,10.0);
BOOST_REQUIRE_SMALL(t.getcputime(),10.0);

Definition at line 25 of file timer.hpp.

#include <timer.hpp>

Public Member Functions

 timer ()
 Default constructor.
 
void start ()
 Start the timer. More...
 
void stop ()
 Stop the timer. More...
 
double getwct ()
 Return the elapsed real time. More...
 
double getcputime ()
 Return the cpu time. More...
 
void reset ()
 Reset the timer. More...
 

Private Member Functions

void check ()
 

Private Attributes

bool running
 Flag that indicate if the timer is running or not.
 
struct timespec tsstart
 starting time
 
clock_t cstart
 start time from epoch
 
struct timespec tsstop
 
clock_t cstop
 stop time from epoch
 

Member Function Documentation

double timer::getcputime ( )
inline

Return the cpu time.

Definition at line 120 of file timer.hpp.

double timer::getwct ( )
inline

Return the elapsed real time.

Definition at line 108 of file timer.hpp.

void timer::reset ( )
inline

Reset the timer.

Definition at line 132 of file timer.hpp.

void timer::start ( )
inline

Start the timer.

Definition at line 73 of file timer.hpp.

void timer::stop ( )
inline

Stop the timer.

Definition at line 97 of file timer.hpp.


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