1 /*
2  * Copyright 2022 NXP
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #pragma once
17 #include <string>
18 
19 class NxpTimer {
20  public:
21   /*
22   ** Constructor
23   */
24   NxpTimer(std::string tag);
25 
26   /*
27   ** Function         startTimer
28   **
29   ** Description      captures starting timestamp
30   **
31   ** Return           void
32   */
33   void startTimer();
34 
35   /*
36   ** Function         stopTimer
37   **
38   ** Description       Captures end timestamp
39   **
40   ** Return           void
41   */
42   void stopTimer();
43 
44   /*
45   ** Function         resetTimer
46   **
47   ** Description       Invalidates the timer state
48   **
49   ** Return           void
50   */
51   void resetTimer();
52 
53   /*
54   ** Function         stopTimer
55   **
56   ** Description       Captures end timestamp
57   **
58   ** Return           void
59   */
60   unsigned long totalDuration();
61 
62   /*
63   ** Function         isRunning
64   **
65   ** Description       Returns true if the timer is running else false
66   **
67   ** Return           bool
68   */
69   bool isRunning();
70 
71   /*
72   ** Destructor
73   */
74   ~NxpTimer();
75 
76  private:
77   unsigned long long start_ts, end_ts;
78   std::string logtag;
79   bool is_running;
80 };
81