• 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  
16  #ifndef SMARTPERF_COMMAND_H
17  #define SMARTPERF_COMMAND_H
18  
19  #include <iostream>
20  #include <vector>
21  #include "profiler.h"
22  namespace OHOS {
23      namespace SmartPerf {
24      class SmartPerfCommand {
25      public:
26          const std::string SmartPerf_EXE_NAME = "SP_daemon";
27  
28          const std::string SmartPerf_VERSION = "1.0.1\n";
29  
30          const std::string SmartPerf_MSG_ERR = "error input!\n use command '--help' get more information\n";
31  
32          const std::string SmartPerf_MSG = "usage: SP_daemon <options> <arguments> \n"
33              "--------------------------------------------------------------------\n"
34              "These are common commands list:\n"
35              " -N             set num of profiler <must be non-null>\n"
36              " -PKG           set pkg_name of profiler \n"
37              " -PID           set process id of profiler \n"
38              " -OUT           set output path of CSV\n"
39              " -c             get cpuFreq and cpuLoad  \n"
40              " -g             get gpuFreq and gpuLoad  \n"
41              " -d             get ddrFreq  \n"
42              " -f             get fps and fps jitters \n"
43              " -t             get soc-temp gpu-temp .. \n"
44              " -p             get current_now and voltage_now \n"
45              " -r             get ram(pss) \n"
46              "--------------------------------------------------------------------\n"
47              "Example: SP_daemon -N 2 -PKG com.ohos.contacts -c -g -t -p -r \n"
48              "--------------------------------------------------------------------\n";
49          const int ONE_PARAM = 1;
50          const int TWO_PARAM = 2;
51          const int THREE_PARAM_MORE = 3;
52          SmartPerfCommand(int argc, char *argv[]);
~SmartPerfCommand()53          ~SmartPerfCommand() {};
54          std::string ExecCommand();
55          // 采集次数
56          int num = 0;
57          // 包名
58          std::string pkgName = "";
59          // csv输出路径
60          std::string outPath = "/data/local/tmp/data.csv";
61          std::string outPathParam = "";
62          // 指定进程pid
63          int pid = 0;
64          // 采集配置项
65          std::vector<std::string> configs;
66          // 采集器设置
67          Profiler *profiler = nullptr;
68      };
69      }
70  }
71  #endif // SMARTPERF_COMMAND_H