OpenFPM_data  0.1.0
Project that contain the implementation and interfaces for basic structure like vectors, grids, graph ... .
 All Data Structures Namespaces Functions Variables Typedefs Friends
timer_util_test.hpp
1 /*
2  * timer_util_test.hpp
3  *
4  * Created on: Jul 11, 2015
5  * Author: i-bird
6  */
7 
8 #ifndef TIMER_UTIL_TEST_HPP_
9 #define TIMER_UTIL_TEST_HPP_
10 
11 #include "timer.hpp"
12 
13 BOOST_AUTO_TEST_SUITE( timer_test )
14 
15 BOOST_AUTO_TEST_CASE( timer_use )
16 {
18  timer t;
19 
20  // start the timer
21  t.start();
22 
23  sleep(1);
24 
25  // get the elapsed real time and cpu time without stop
26  BOOST_REQUIRE_CLOSE(t.getwct(),1.0,10.0);
27  BOOST_REQUIRE_SMALL(t.getcputime(),10.0);
28 
29  sleep(1);
30 
31  // stop the timer
32  t.stop();
33 
34  sleep(1);
35 
36  // unusefull
37  t.stop();
38 
39  // get the cpu time and real time
40  t.getcputime();
41  t.getwct();
42 
43  // get the elapsed real time and cpu time without stop
44  BOOST_REQUIRE_CLOSE(t.getwct(),2.0,10.0);
45  BOOST_REQUIRE_SMALL(t.getcputime(),10.0);
46 
47  t.reset();
48 
49  BOOST_REQUIRE_CLOSE(t.getwct(),0.0,10.0);
50  BOOST_REQUIRE_SMALL(t.getcputime(),10.0);
51 
53 }
54 
55 BOOST_AUTO_TEST_SUITE_END()
56 
57 
58 #endif /* TIMER_UTIL_TEST_HPP_ */
double getwct()
Return the elapsed real time.
Definition: timer.hpp:102
double getcputime()
Return the cpu time.
Definition: timer.hpp:114
void start()
Start the timer.
Definition: timer.hpp:67
void reset()
Reset the timer.
Definition: timer.hpp:126
Class for cpu time benchmarking.
Definition: timer.hpp:25
void stop()
Stop the timer.
Definition: timer.hpp:91