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_TEMPERATURE, 33 GET_POWER, 34 GET_CAPTURE, 35 CATCH_TRACE_START, 36 CATCH_TRACE_FINISH, 37 SET_DUBAI_DB 38 }; 39 40 const std::unordered_map<MessageType, std::string> messageMap = { 41 { MessageType::GET_CPU_NUM, std::string("get_cpu_num") }, 42 { MessageType::GET_CPU_FREQ, std::string("get_cpu_freq") }, 43 { MessageType::GET_CPU_LOAD, std::string("get_cpu_load") }, 44 { MessageType::SET_PKG_NAME, std::string("set_pkgName") }, 45 { MessageType::SET_PROCESS_ID, std::string("set_pid") }, 46 { MessageType::GET_FPS_AND_JITTERS, std::string("get_fps_and_jitters") }, 47 { MessageType::GET_GPU_FREQ, std::string("get_gpu_freq") }, 48 { MessageType::GET_GPU_LOAD, std::string("get_gpu_load") }, 49 { MessageType::GET_DDR_FREQ, std::string("get_ddr_freq") }, 50 { MessageType::GET_RAM_INFO, std::string("get_ram_info") }, 51 { MessageType::GET_TEMPERATURE, std::string("get_temperature") }, 52 { MessageType::GET_POWER, std::string("get_power") }, 53 { MessageType::GET_CAPTURE, std::string("get_capture") }, 54 { MessageType::CATCH_TRACE_START, std::string("catch_trace_start") }, 55 { MessageType::CATCH_TRACE_FINISH, std::string("catch_trace_end") }, 56 { MessageType::SET_DUBAI_DB, std::string("set_dubai_db") }, 57 }; 58 59 enum class CommandType { 60 CT_N, 61 CT_PKG, 62 CT_PID, 63 CT_OUT, 64 CT_C, 65 CT_G, 66 CT_D, 67 CT_F, 68 CT_F1, 69 CT_F2, 70 CT_T, 71 CT_P, 72 CT_R, 73 CT_TTRACE, 74 CT_SNAPSHOT, 75 CT_HW, 76 CT_SESSIONID, 77 CT_INTERVAL 78 }; 79 enum class CommandHelp { 80 HELP, 81 VERSION 82 }; 83 84 const std::unordered_map<std::string, CommandType> commandMap = { 85 { std::string("-N"), CommandType::CT_N }, { std::string("-PKG"), CommandType::CT_PKG }, 86 { std::string("-PID"), CommandType::CT_PID }, { std::string("-OUT"), CommandType::CT_OUT }, 87 { std::string("-c"), CommandType::CT_C }, { std::string("-g"), CommandType::CT_G }, 88 { std::string("-f"), CommandType::CT_F }, { std::string("-f1"), CommandType::CT_F1 }, 89 { std::string("-f2"), CommandType::CT_F1 }, { std::string("-t"), CommandType::CT_T }, 90 { std::string("-p"), CommandType::CT_P }, { std::string("-r"), CommandType::CT_R }, 91 { std::string("-trace"), CommandType::CT_TTRACE }, { std::string("-snapshot"), CommandType::CT_SNAPSHOT }, 92 { std::string("-hw"), CommandType::CT_HW }, { std::string("-d"), CommandType::CT_D }, 93 { std::string("-INTERVAL"), CommandType::CT_INTERVAL }, { std::string("-SESSIONID"), CommandType::CT_SESSIONID }, 94 }; 95 96 const std::unordered_map<CommandType, std::string> COMMAND_MAP_REVERSE = { 97 { CommandType::CT_N, std::string("-N") }, { CommandType::CT_PKG, std::string("-PKG") }, 98 { CommandType::CT_PID, std::string("-PID") }, { CommandType::CT_OUT, std::string("-OUT") }, 99 { CommandType::CT_C, std::string("-c") }, { CommandType::CT_G, std::string("-g") }, 100 { CommandType::CT_F, std::string("-f") }, { CommandType::CT_F1, std::string("-f1") }, 101 { CommandType::CT_F1, std::string("-f2") }, { CommandType::CT_T, std::string("-t") }, 102 { CommandType::CT_P, std::string("-p") }, { CommandType::CT_R, std::string("-r") }, 103 { CommandType::CT_TTRACE, std::string("-trace") }, { CommandType::CT_SNAPSHOT, std::string("-snapshot") }, 104 { CommandType::CT_HW, std::string("-hw") }, { CommandType::CT_D, std::string("-d") }, 105 { CommandType::CT_INTERVAL, std::string("-INTERVAL") }, { CommandType::CT_SESSIONID, std::string("-SESSIONID") }, 106 }; 107 108 109 const std::unordered_map<CommandHelp, std::string> commandHelpMap = { 110 { CommandHelp::HELP, std::string("--help") }, 111 { CommandHelp::VERSION, std::string("--version") }, 112 }; 113 114 enum class TraceStatus { 115 TRACE_START, 116 TRACE_FINISH, 117 TRACE_NO 118 }; 119 } 120 } 121 #endif