GCC Code Coverage Report


Directory: ./
File: src/PTimer.cpp
Date: 2025-03-25 16:20:12
Exec Total Coverage
Lines: 35 35 100.0%
Branches: 3 3 100.0%

Line Branch Exec Source
1 /***************************************
2 Auteur : Pierre Aubert
3 Mail : pierre.aubert@lapp.in2p3.fr
4 Licence : CeCILL-C
5 ****************************************/
6
7 #include "PTimer.h"
8
9 ///Default constructor of PTimer
10 /** @param ellapsedTime : ellapsed time between two calls (in nanoseconds)
11 */
12 3 PTimer::PTimer(time_t ellapsedTime)
13 3 :p_startTime(0l),
14 3 p_ellapsedTime(ellapsedTime)
15 {
16 3 initialisationPTimer();
17 3 }
18
19 ///Copy constructor of PTimer
20 /** @param other : class to copy
21 */
22 1 PTimer::PTimer(const PTimer & other){
23 1 copyPTimer(other);
24 1 }
25
26 ///Destructor of PTimer
27 8 PTimer::~PTimer(){
28
29 }
30
31 ///Definition of equal operator of PTimer
32 /** @param other : class to copy
33 * @return copied class
34 */
35 1 PTimer & PTimer::operator = (const PTimer & other){
36 1 copyPTimer(other);
37 1 return *this;
38 }
39
40 ///Start the current clock
41 /** @param currentTime : current time
42 */
43 2 void PTimer::setStartTime(time_t currentTime){
44 2 p_startTime = currentTime;
45 2 }
46
47 ///Set the ellapsed time in nanoseconds
48 /** @param ellapsedTime : ellapsed time in nanoseconds
49 */
50 1 void PTimer::setEllapsedTime(time_t ellapsedTime){
51 1 p_ellapsedTime = ellapsedTime;
52 1 }
53
54 ///Get the ellapsed time in nanoseconds
55 /** @return ellapsed time in nanoseconds
56 */
57 2 time_t PTimer::getEllapsedTime() const{
58 2 return p_ellapsedTime;
59 }
60
61 ///Returns true if the given ellapsed time between to call is passed
62 /** @param currentTime : current time
63 * @return true if the given ellapsed time between to call is passed, false otherwise
64 */
65 2 bool PTimer::isTime(time_t currentTime){
66 2 time_t ellapsedTimeNs(0lu);
67
1/1
✓ Branch 1 taken 2 times.
4 return isTime(ellapsedTimeNs, currentTime);
68 }
69
70 ///Returns true if the given ellapsed time between to call is passed
71 /** @param[out] ellapsedTimeNs : real ellapsed time in nanoseconds between the call of isTime and the last start of the PTimer (maybe in another isTime)
72 * @param currentTime : current time
73 * @return true if the given ellapsed time between to call is passed, false otherwise
74 */
75 2 bool PTimer::isTime(time_t & ellapsedTimeNs, time_t currentTime){
76 2 ellapsedTimeNs = currentTime - p_startTime;
77 2 bool b(ellapsedTimeNs >= p_ellapsedTime);
78
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 if(b){
79 1 setStartTime(currentTime);
80 }
81 2 return b;
82 }
83
84 ///Copy function of PTimer
85 /** @param other : class to copy
86 */
87 2 void PTimer::copyPTimer(const PTimer & other){
88 2 p_ellapsedTime = other.p_ellapsedTime;
89 2 p_startTime = other.p_startTime;
90 2 }
91
92 ///Initialisation function of the class PTimer
93 3 void PTimer::initialisationPTimer(){
94
95 3 }
96
97