• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef COMMON_H
16 #define COMMON_H
17 #include <unordered_map>
18 #include <string>
19 namespace OHOS {
20 namespace SmartPerf {
21 enum class MessageType {
22     GET_CPU_NUM,
23     GET_CPU_FREQ,
24     GET_CPU_LOAD,
25     SET_PKG_NAME,
26     SET_PROCESS_ID,
27     GET_FPS_AND_JITTERS,
28     GET_GPU_FREQ,
29     GET_GPU_LOAD,
30     GET_DDR_FREQ,
31     GET_RAM_INFO,
32     GET_MEMORY_INFO,
33     GET_TEMPERATURE,
34     GET_POWER,
35     GET_CAPTURE,
36     CATCH_TRACE_CONFIG,
37     CATCH_TRACE_CMD,
38     SET_DUBAI_DB,
39     GPU_COUNTER_HB_REQ,
40     CATCH_GPU_COUNTER,      // 请求抓取GPU counter信息
41     GET_GPU_COUNTER_RESULT, // 获取GPU counter信息
42     CATCH_NETWORK_TRAFFIC,
43     GET_NETWORK_TRAFFIC, // 获取网络流量信息
44     BACK_TO_DESKTOP,
45 };
46 
47 const std::unordered_map<MessageType, std::string> MESSAGE_MAP = {
48     { MessageType::GET_CPU_NUM, std::string("get_cpu_num") },
49     { MessageType::GET_CPU_FREQ, std::string("get_cpu_freq") },
50     { MessageType::GET_CPU_LOAD, std::string("get_cpu_load") },
51     { MessageType::SET_PKG_NAME, std::string("set_pkgName") },
52     { MessageType::SET_PROCESS_ID, std::string("set_pid") },
53     { MessageType::GET_FPS_AND_JITTERS, std::string("get_fps_and_jitters") },
54     { MessageType::GET_GPU_FREQ, std::string("get_gpu_freq") },
55     { MessageType::GET_GPU_LOAD, std::string("get_gpu_load") },
56     { MessageType::GET_DDR_FREQ, std::string("get_ddr_freq") },
57     { MessageType::GET_RAM_INFO, std::string("get_ram_info") },
58     { MessageType::GET_TEMPERATURE, std::string("get_temperature") },
59     { MessageType::GET_POWER, std::string("get_power") },
60     { MessageType::GET_CAPTURE, std::string("get_capture") },
61     { MessageType::GET_MEMORY_INFO, std::string("get_memory") },
62     { MessageType::CATCH_TRACE_CONFIG, std::string("catch_trace_config") },
63     { MessageType::CATCH_TRACE_CMD, std::string("catch_trace_cmd") },
64     { MessageType::SET_DUBAI_DB, std::string("set_dubai_db") },
65     { MessageType::GPU_COUNTER_HB_REQ, std::string("gpu_counter_hb_req") },
66     { MessageType::CATCH_GPU_COUNTER, std::string("catch_gpu_counter") },
67     { MessageType::GET_GPU_COUNTER_RESULT, std::string("get_gpu_counter_result") },
68     { MessageType::CATCH_NETWORK_TRAFFIC, std::string("catch_network_traffic") },
69     { MessageType::GET_NETWORK_TRAFFIC, std::string("get_network_traffic") },
70     { MessageType::BACK_TO_DESKTOP, std::string("back_to_desk") },
71 };
72 
73 enum class CommandType {
74     CT_N,
75     CT_PKG,
76     CT_PID,
77     CT_OUT,
78     CT_C,
79     CT_G,
80     CT_D,
81     CT_F,
82     CT_T,
83     CT_P,
84     CT_R,
85     CT_TTRACE,
86     CT_SNAPSHOT,
87     CT_HW,
88     CT_SESSIONID,
89     CT_INTERVAL,
90     CT_NET,
91     CT_VIEW,
92     CT_FL,
93     CT_FTL,
94     CT_M,
95 };
96 enum class CommandHelp {
97     HELP,
98     VERSION,
99     SCREEN,
100 };
101 
102 const std::unordered_map<std::string, CommandType> COMMAND_MAP = {
103     { std::string("-N"), CommandType::CT_N },
104     { std::string("-PKG"), CommandType::CT_PKG },
105     { std::string("-PID"), CommandType::CT_PID },
106     { std::string("-OUT"), CommandType::CT_OUT },
107     { std::string("-c"), CommandType::CT_C },
108     { std::string("-g"), CommandType::CT_G },
109     { std::string("-f"), CommandType::CT_F },
110     { std::string("-t"), CommandType::CT_T },
111     { std::string("-p"), CommandType::CT_P },
112     { std::string("-r"), CommandType::CT_R },
113     { std::string("-trace"), CommandType::CT_TTRACE },
114     { std::string("-snapshot"), CommandType::CT_SNAPSHOT },
115     { std::string("-hw"), CommandType::CT_HW },
116     { std::string("-d"), CommandType::CT_D },
117     { std::string("-INTERVAL"), CommandType::CT_INTERVAL },
118     { std::string("-SESSIONID"), CommandType::CT_SESSIONID },
119     { std::string("-net"), CommandType::CT_NET },
120     { std::string("-VIEW"), CommandType::CT_VIEW },
121     { std::string("-fl"), CommandType::CT_FL },
122     { std::string("-ftl"), CommandType::CT_FTL },
123     { std::string("-m"), CommandType::CT_M },
124 };
125 
126 const std::unordered_map<CommandType, std::string> COMMAND_MAP_REVERSE = {
127     { CommandType::CT_N, std::string("-N") },
128     { CommandType::CT_PKG, std::string("-PKG") },
129     { CommandType::CT_PID, std::string("-PID") },
130     { CommandType::CT_OUT, std::string("-OUT") },
131     { CommandType::CT_C, std::string("-c") },
132     { CommandType::CT_G, std::string("-g") },
133     { CommandType::CT_F, std::string("-f") },
134     { CommandType::CT_T, std::string("-t") },
135     { CommandType::CT_P, std::string("-p") },
136     { CommandType::CT_R, std::string("-r") },
137     { CommandType::CT_TTRACE, std::string("-trace") },
138     { CommandType::CT_SNAPSHOT, std::string("-snapshot") },
139     { CommandType::CT_HW, std::string("-hw") },
140     { CommandType::CT_D, std::string("-d") },
141     { CommandType::CT_INTERVAL, std::string("-INTERVAL") },
142     { CommandType::CT_SESSIONID, std::string("-SESSIONID") },
143     { CommandType::CT_NET, std::string("-net") },
144     { CommandType::CT_VIEW, std::string("-VIEW") },
145     { CommandType::CT_FL, std::string("-fl") },
146     { CommandType::CT_FTL, std::string("-ftl") },
147     { CommandType::CT_M, std::string("-m") },
148 };
149 
150 
151 const std::unordered_map<CommandHelp, std::string> COMMAND_HELP_MAP = {
152     { CommandHelp::HELP, std::string("--help") },
153     { CommandHelp::VERSION, std::string("--version") },
154     { CommandHelp::SCREEN, std::string("-screen") },
155 };
156 
157 enum class TraceStatus {
158     TRACE_START,
159     TRACE_FINISH,
160     TRACE_NO
161 };
162 }
163 }
164 #endif