OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
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
13BOOST_AUTO_TEST_SUITE( timer_test )
14
15BOOST_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,20.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,20.0);
45 BOOST_REQUIRE_SMALL(t.getcputime(),10.0);
46
47 t.reset();
48
49 BOOST_REQUIRE_CLOSE(t.getwct(),0.0,20.0);
50 BOOST_REQUIRE_SMALL(t.getcputime(),10.0);
51
53}
54
55BOOST_AUTO_TEST_SUITE_END()
56
57
58#endif /* TIMER_UTIL_TEST_HPP_ */
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