1 |
|
|
|
2 |
|
|
/*************************************** |
3 |
|
|
Auteur : Pierre Aubert |
4 |
|
|
Mail : pierre.aubert@lapp.in2p3.fr |
5 |
|
|
Licence : CeCILL-C |
6 |
|
|
****************************************/ |
7 |
|
|
|
8 |
|
|
#include <iostream> |
9 |
|
|
#include "PTimer.h" |
10 |
|
|
|
11 |
|
|
///Test the PTimer |
12 |
|
|
/** @return true on success, false otherwise |
13 |
|
|
*/ |
14 |
|
1 |
bool testPTimer(){ |
15 |
✓ |
2 |
PTimer timer1(1000000000lu); |
16 |
✓ |
2 |
PTimer timer2; |
17 |
✓ |
1 |
timer2.setEllapsedTime(100000000lu); |
18 |
|
|
|
19 |
|
1 |
size_t counter(0lu), counterTimer2(0lu); |
20 |
✓✓✓ |
8116155 |
while(!timer1.isTime()){ |
21 |
|
8116154 |
size_t ellapsedTimeNs(0lu); |
22 |
✓✓✓ |
8116154 |
if(timer2.isTime(ellapsedTimeNs)){ |
23 |
✓✓✓✓
|
9 |
std::cerr << counterTimer2 << " : " << ellapsedTimeNs << std::endl; |
24 |
|
9 |
++counterTimer2; |
25 |
|
|
} |
26 |
|
8116154 |
++counter; |
27 |
|
|
} |
28 |
✓✓✓ |
1 |
std::cout << "counter\t= " << counter << std::endl; |
29 |
✓✓✓ |
1 |
std::cout << "counterTimer2\t= " << counterTimer2 << std::endl; |
30 |
|
|
|
31 |
|
1 |
bool b(true); |
32 |
✓ |
1 |
b &= timer1.getEllapsedTime() == 1000000000lu; |
33 |
✓ |
1 |
b &= timer2.getEllapsedTime() == 100000000lu; |
34 |
✓✓ |
2 |
PTimer timer3(timer2), timer4; |
35 |
✓ |
1 |
timer4 = timer1; |
36 |
|
|
|
37 |
✓ |
1 |
b &= timer4.getEllapsedTime() == 1000000000lu; |
38 |
✓ |
1 |
b &= timer3.getEllapsedTime() == 100000000lu; |
39 |
|
2 |
return b; |
40 |
|
|
} |
41 |
|
|
|
42 |
|
|
|
43 |
|
|
|
44 |
|
1 |
int main(int argc, char** argv){ |
45 |
|
1 |
bool b(true); |
46 |
|
1 |
b &= testPTimer(); |
47 |
|
1 |
std::cout << "Final b = " << b << std::endl; |
48 |
|
1 |
return b - 1; |
49 |
|
|
} |
50 |
|
|
|
51 |
|
|
|