OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
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,20.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,20.0);
BOOST_REQUIRE_SMALL(t.getcputime(),10.0);
t.reset();
BOOST_REQUIRE_CLOSE(t.getwct(),0.0,20.0);
BOOST_REQUIRE_SMALL(t.getcputime(),10.0);
Class for cpu time benchmarking.
Definition timer.hpp:28
void stop()
Stop the timer.
Definition timer.hpp:119
double getcputime()
Return the cpu time.
Definition timer.hpp:142
void reset()
Reset the timer.
Definition timer.hpp:154
void start()
Start the timer.
Definition timer.hpp:90
double getwct()
Return the elapsed real time.
Definition timer.hpp:130

Definition at line 27 of file timer.hpp.

#include <timer.hpp>

Public Member Functions

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

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
 

Constructor & Destructor Documentation

◆ timer()

timer::timer ( )
inline

Default constructor.

Definition at line 80 of file timer.hpp.

Member Function Documentation

◆ check()

void timer::check ( )
inlineprivate

Definition at line 53 of file timer.hpp.

◆ getcputime()

double timer::getcputime ( )
inline

Return the cpu time.

Definition at line 142 of file timer.hpp.

◆ getwct()

double timer::getwct ( )
inline

Return the elapsed real time.

Definition at line 130 of file timer.hpp.

◆ reset()

void timer::reset ( )
inline

Reset the timer.

Definition at line 154 of file timer.hpp.

◆ start()

void timer::start ( )
inline

Start the timer.

Definition at line 90 of file timer.hpp.

◆ stop()

void timer::stop ( )
inline

Stop the timer.

Definition at line 119 of file timer.hpp.

Field Documentation

◆ cstart

clock_t timer::cstart
private

start time from epoch

Definition at line 36 of file timer.hpp.

◆ cstop

clock_t timer::cstop
private

stop time from epoch

Definition at line 42 of file timer.hpp.

◆ running

bool timer::running
private

Flag that indicate if the timer is running or not.

Definition at line 30 of file timer.hpp.

◆ tsstart

struct timespec timer::tsstart
private

starting time

Definition at line 33 of file timer.hpp.

◆ tsstop

struct timespec timer::tsstop
private

Definition at line 39 of file timer.hpp.


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