2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 //////////////////////////////////////////////////////////////////////////////////////////////////
18 /// \ingroup tag_NSFramework
19 /// \brief File declares FrameworkunifiedMsgProfiler class which keeps profiler information for message dispatcher
23 //////////////////////////////////////////////////////////////////////////////////////////////////
25 #ifndef FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_FRAMEWORKUNIFIED_MSGPROFILER_H_
26 #define FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_FRAMEWORKUNIFIED_MSGPROFILER_H_
28 #include <native_service/frameworkunified_types.h>
32 ///////////////////////////////////////////////////////////////////////////////////////////////////
33 /// Profiler class which keeps and manage profiler information for message dispatcher
34 ///////////////////////////////////////////////////////////////////////////////////////////////////
35 class FrameworkunifiedMsgProfiler {
37 ///////////////////////////////////////////////////////////////////////////////////////////
38 /// FrameworkunifiedMsgProfiler
39 /// Parameterized constructor
40 /// \param [in] f_cAppName
41 /// const std::string& - Name of the application or dispatcher
44 ///////////////////////////////////////////////////////////////////////////////////////////
45 explicit FrameworkunifiedMsgProfiler(const std::string &f_cAppName);
47 ///////////////////////////////////////////////////////////////////////////////////////////
48 /// ~FrameworkunifiedMsgProfiler
52 ///////////////////////////////////////////////////////////////////////////////////////////
53 ~FrameworkunifiedMsgProfiler();
55 ///////////////////////////////////////////////////////////////////////////////////////////
57 /// Returns application name corresponding to profiler
61 /// \return std::string
62 /// std::string - Returns application name corresponding to profiler
64 ///////////////////////////////////////////////////////////////////////////////////////////
65 std::string GetAppName();
67 ///////////////////////////////////////////////////////////////////////////////////////////
69 /// Returns application name corresponding to profiler
71 /// \param [in] f_cChildName
72 /// const std::string& - Add the name of child dispatcher profiler
76 ///////////////////////////////////////////////////////////////////////////////////////////
77 VOID AddChildName(const std::string &f_cChildName);
79 ///////////////////////////////////////////////////////////////////////////////////////////
81 /// Updates the profiler information once the message is received.
82 /// e.g. increaments msg count, save the time of msg received
88 ///////////////////////////////////////////////////////////////////////////////////////////
91 ///////////////////////////////////////////////////////////////////////////////////////////
93 /// Updates the profiler information once the message is processed.
94 /// e.g. Updates the frequency of execution of message
100 ///////////////////////////////////////////////////////////////////////////////////////////
103 ///////////////////////////////////////////////////////////////////////////////////////////
105 /// All the profiler information which FrameworkunifiedMsgProfiler class has prints it in message
106 /// queue FRAMEWORKUNIFIED_NS_MSGPROFILERUTIL
108 /// \param [in] f_hApp
109 /// HANDLE - Application framework handle
112 /// EFrameworkunifiedStatus - success or failure
114 ///////////////////////////////////////////////////////////////////////////////////////////
115 EFrameworkunifiedStatus PrintProfileInfo(HANDLE f_hApp);
117 static BOOL m_bMsgProfilerEnabled; /// Flag is enabled when command line argument -q is passed.
118 /// Otherwise no profiler information is maintained.
121 ///////////////////////////////////////////////////////////////////////////////////////////
123 /// GetClock of milliseconds
128 /// UI_64 - returns time in Milliseconds
130 ///////////////////////////////////////////////////////////////////////////////////////////
133 std::vector<std::string> m_vChildNames; /// vector to save list of all child threads dispatcher
134 std::string m_cAppName; /// Dispacther application name
135 UI_32 m_ui32TotalNoOfMsgsReceived; /// Total number of messages received by the dispatcher
137 // NOTE: Storing time in ClockCycle. So that it will not add overhead for converting it to miliseconds.
138 // It will get converted only when information is required to print.
139 UI_64 m_ui64MinMsgProcessingTime; // time is in clock cycles
140 UI_64 m_ui64MaxMsgProcessingTime; // time is in clock cycles
142 UI_64 m_ui64TotalMsgExecutionTime; /// total time spent in message execution
143 UI_64 m_ui64LastMsgReceivedTime; /// save the time when last message was received
144 UI_64 m_ui64AppInitTime; /// save the time when application got initialized
145 BOOL m_bLastMsgWasPrintProfile; /// TRUE if the last message received
148 #endif // FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_FRAMEWORKUNIFIED_MSGPROFILER_H_