diff --git a/README_zh.md b/README_zh.md
index 38e2cebaeb239a565687682defad1e7cb7f6742b..934b9ab7ee671aff2cd28873ef46608cd232ae26 100644
--- a/README_zh.md
+++ b/README_zh.md
@@ -1,27 +1,24 @@
# SmartPerf
-- [简介](#简介)
-- [目录](#目录)
-- [约束](#约束)
-- [相关文档](#相关文档)
-
## 简介
-- **SmartPerf** 是一款基于OpenHarmony系统开发的性能功耗测试分析工具,支持两个组成部分: SP-Device端和SP-Host端。
-- **SP-Device端:** 是一款初级的,粗粒度的数据采集分析的性能功耗测试工具。支持FPS、功耗、热、Soc信息的实时采集、实时展示、数据报告生成。
-- **SP-Host端:** 是一款深入挖掘数据、细粒度的展示数据的性能功耗测试工具。支持CPU调度、频点、进程线程时间片、堆内存、FPS数据采集和展示。支持在泳道图中展示非实时的采集数据,支持GUI操作数据分析。
+- **SmartPerf** 是基于OpenHarmony系统开发的性能、功耗测试工具链,支持两个组成部分:设备端的Device工具和PC端的Host工具。
+- **Device工具:** 是一款初级的、粗粒度的数据采集性能、功耗测试工具,支持帧率、功耗、热、Soc信息的实时采集、实时展示、数据报告生成。
+- **Host工具:** 是一款深入挖掘数据、细粒度的展示数据的性能、功耗测试工具,支持CPU调度、频点、进程线程时间片、堆内存、FPS数据采集和展示,支持在泳道图中展示非实时的采集数据,支持GUI操作数据分析。
其主要的结构如下图所示:
-
+
## 目录
```
-/developtools/smartperf
+/smartperf
├── device # device端 相关代码
│ ├── device_command # device端 命令行方式采集代码
│ ├── device_ui # device端 GUI方式采集代码
+│ ├── figures # device端 相关截图
+├── figures # 相关截图
├── host # host端 相关代码
│ ├── doc # host端 相关使用文档
│ ├── ide # host端 IDE 模块目录
@@ -53,13 +50,10 @@ host端构建约束
## 相关文档
-- [device_command_line_collection](https://gitee.com/openharmony/developtools_profiler/blob/master/host/smartperf/doc/quickstart_trace_streamer.md)
-- [device_ui_collection](https://gitee.com/openharmony/developtools_profiler/blob/master/host/smartperf/doc/quickstart_trace_streamer.md)
-- [quickstart_trace_streamer](https://gitee.com/openharmony/developtools_profiler/blob/master/host/smartperf/doc/quickstart_trace_streamer.md)
-- [quickstart_smartperf](https://gitee.com/openharmony/developtools_profiler/blob/master/host/smartperf/doc/quickstart_smartperf.md)
-- [quickstart_hiprofiler_cmd](https://gitee.com/openharmony/developtools_profiler/blob/master/host/smartperf/doc/quickstart_hiprofiler_cmd.md)
-- [compile_smartperf](https://gitee.com/openharmony/developtools_profiler/blob/master/host/smartperf/doc/compile_smartperf.md)
-- [compile_trace_streamer](https://gitee.com/openharmony/developtools_profiler/blob/master/host/smartperf/doc/compile_trace_streamer.md)
-- [des_stat](https://gitee.com/openharmony/developtools_profiler/blob/master/host/smartperf/doc/des_stat.md)
-- [des_support_event](https://gitee.com/openharmony/developtools_profiler/blob/master/host/smartperf/doc/des_support_event.md)
-- [des_tables](https://gitee.com/openharmony/developtools_profiler/blob/master/host/smartperf/doc/des_tables.md)
\ No newline at end of file
+
+- [SmartPerf Device工具使用说明](device/README_zh.md)
+- [SmartPerf Device工具客户端使用说明](device/device_ui/README_zh.md)
+- [SmartPerf Device工具服务端使用说明](device/device_command/README_zh.md)
+- [SmartPerf Host工具的运行和使用方法](host/doc/quickstart_smartperf.md)
+- [SmartPerf Host工具编译网页可运行环境](host/doc/compile_smartperf.md)
+- [SmartPerf Host工具编译数据解析文件](host/doc/compile_trace_streamer.md)
\ No newline at end of file
diff --git a/device/README_zh.md b/device/README_zh.md
index cf54a239f8f15669311c4053fc71a5c00eecd114..baa22921d482d73517089dda92b4e93d72452f4a 100644
--- a/device/README_zh.md
+++ b/device/README_zh.md
@@ -1,47 +1,47 @@
-# SmartPerf(Device、Daemon)
+# Device
## 概述
-为支撑OpenHarmony性能测试,我们向用户提供了符合功能需求并且可靠、易用的性能测试工具。支持开发者针对应用进行相应的性能数据采集以及指标计算功能。
+为支撑OpenHarmony性能测试,我们向用户提供了符合功能需求并且可靠、易用的性能测试工具,支持开发者针对应用进行相应的性能数据采集以及指标计算功能。
## 简介
-SmartPerf(Device、Daemon)是基于OpenHarmony系统开发的性能功耗测试工具,操作简单易用,可提供包括性能、功耗的关键KPI指标,给出具体指标的测试值,包括采集设备的FPS、CPU、GPU、Ftrace等指标数据;
+Device是基于OpenHarmony系统开发的性能功耗测试工具,操作简单易用,可提供包括性能、功耗的关键KPI指标,给出具体指标的测试值,包括采集设备的帧率、soc信息等指标数据;
-目前SmartPerf(Device、Daemon)工具提供了两种使用方式,分别为hap应用可视化操作方式(SmartPerf-Device)和shell命令行方式(SmartPerf-Daemon),其中SmartPerf-Device支持可视化操作、悬浮窗控制暂停,悬浮窗实时展示数据,SmartPerf-Daemon主要适用于无屏设备、性能较差的设备,对3568等设备同样支持。
+目前Device工具提供了两种使用方式,分别为Device客户端(Hap应用名称:SmartPerf)可视化的使用方式和Device服务端(bin名称:SP_daemon)shell命令行的使用方式,其中Device客户端支持悬浮窗控制采集、悬浮窗实时展示数据、图形化展示报告等功能,Device服务端支持shell中启动测试、实时打印数据、报告保存等功能。
## 实现原理
-SmartPerf工具主要包括SmartPerf-Device、SmartPerf-Daemon两个部分,其中Device采集的FPS、RAM、Trace等指标需要通过发送消息给Daemon端去采集数据,然后接收Daemon回传的数据展示,同时Daemon端也提供了shell命令的方式单独执行采集,工具的主要功能组成如下图:
+Device客戶端采集的FPS、RAM等指标需要通过发送消息给Device服务端去采集数据,然后接收Device服务端回传的数据,然后进行展示,同时Device服务端支持单独执行shell命令的方式启动采集,工具的主要功能组成如下图:

## 约束与限制
-1.SmartPerf-Device、SmartPerf-Daemon在3.2系统版本后开始预制使用。
+1.Device客户端、Device服务端在3.2.5.1版本后开始预制使用。
-2.其中SmartPerf-Device的使用必须是具备屏幕的设备。
+2.其中Device客户端只能在具备屏幕的设备上使用。
## 环境准备
-SmartPerf-Daemon执行需要PC连接OpenHarmony设备,如RK3568开发板等。
+Device服务端的执行需要使用PC连接OpenHarmony设备,如RK3568开发板等。
## 执行性能测试
-**SmartPerf-Device应用可视化使用示例,详细请参考[SmartPerf-Device使用](device_ui/README_zh.md)**
+**Device客户端(Hap应用名称:SmartPerf)可视化使用示例,详细请参考[Device客户端使用](device_ui/README_zh.md)**
-以下SmartPerf-Device应用内截图以RK3568设备为例。
+以下Device客户端应用内截图,以RK3568设备为例。
1.应用采集配置。
-启动SmartPerf-Device进入首页,选择测试应用、测试指标项,点击”开始测试“,拉起测试应用。
+启动SmartPerf-Device进入首页,选择测试应用、测试指标项,点击“开始测试”,拉起测试应用。



2.悬浮窗控制采集。
-点击悬浮窗”start“开始采集,单击悬浮窗”计时器“暂停采集,再次单击继续采集双击计时器,实时展示采集数据,可拖动悬浮框更改悬浮框位置,长按”计时器“,结束采集。
+点击悬浮窗“start”开始采集,单击悬浮窗“计时器”暂停采集,再次单击继续采集,双击计时器实时展示采集数据,可拖动悬浮框更改悬浮框位置,长按“计时器”结束采集。


@@ -53,7 +53,7 @@ SmartPerf-Daemon执行需要PC连接OpenHarmony设备,如RK3568开发板等。


-**SmartPerf-Daemon命令行使用示例,详细请参考[SmartPerf-Daemon使用](device_command/README_zh.md)**
+**Device服务端(bin名称:SP_daemon)命令行使用示例,详细请参考[Device服务端](device_command/README_zh.md)**
1.进入shell, 执行查看帮助命令。
```
diff --git a/device/device_command/README_zh.md b/device/device_command/README_zh.md
index 3b7cf07eb916f1ea9194585a440fb891a516f786..6cb635d32e0c89080352053b5795ef3777908a8f 100644
--- a/device/device_command/README_zh.md
+++ b/device/device_command/README_zh.md
@@ -1,15 +1,15 @@
-# SmartPerf-Daemon(SP_daemon)
+# Device服务端(bin名称:SP_daemon)
## 简介
-- OpenHarmony性能测试工具SmartPerf 命令行版本,可采集CPU、GPU、Temperature、Power、应用RAM、FPS等指标,通过设置采集指标,对采集数据进行实时打印、导出csv。
+- OpenHarmony性能测试工具Device服务端,可通过执行shell命令采集帧率、CPU、GPU、Temperature、Power、应用RAM等指标,通过设置采集指标,对采集数据进行实时打印、导出csv。
-- 性能较差或无屏幕设备请使用命令行版本,带屏幕的设备且性能较好的设备推荐使用[UI版本](../device_ui/README_zh.md)。
+- 性能较差或无屏幕设备请使用Device服务端执行采集,带屏幕的设备且性能较好的设备推荐使用[Device客户端](../device_ui/README_zh.md)。
## 代码目录
```
/smartperf/device/device_command
├── include # 头文件目录
-├── BUILD.gn # SP_daemon bin打包配置文件
+├── BUILD.gn # 打包配置文件
├── ByTrace.cpp # trace抓取代码文件
├── Capture.cpp # 截图代码文件
├── CPU.cpp # CPU采集代码文件
@@ -21,13 +21,13 @@
├── smartperf_command.cpp # 程序执行文件
├── smartperf_main.cpp # 程序入口文件
├── sp_profiler_factory.cpp # 采集工厂文件
-├── sp_server_socket.cpp # 与SmartPerf hap通讯代码文件
+├── sp_server_socket.cpp # 与Device客户端通讯代码文件
├── sp_utils.cpp # 工具类
├── Temperature.cpp # 温度采集代码文件
```
## 约束条件
- SmartPerf应用在3.2系统版本后开始预制使用。
+ Device服务端在3.2.5.1系统版本后开始预制使用。
## 功能特性
@@ -44,13 +44,13 @@
| -f | 是否采集fps。 |否|
| -t | 是否采集温度。 |否|
| -p | 是否采集电流。 |否|
-| -r | 是否采集内存(需指定进程pid)。 |否|
+| -r | 是否采集内存(需指定进程pid)。 |否|
| -snapshot | 是否截图。 |否|
---
**2. 使用方式**
-1)目前命令行版本已系统预制,可以进入shell,执行SP_daemon --help查看。
+1)目前Device服务端已系统预制,可以进入shell,执行SP_daemon --help查看。
```bash
C:\Users\test>hdc_std shell
@@ -125,7 +125,7 @@ cpu0freq,cpu0load,cpu1freq,cpu1load,cpu2freq,cpu2load,cpu3freq,cpu3load,current_
## 发布版本
-**3.2.0.0版本发布内容:预制SP_daemon bin文件,支持以下功能:**
+**3.2.5.1版本发布内容:预制Device服务端,支持以下功能:**
1. 支持RK3568、Hi3516。
2. 支持Shell启动。
3. 支持采集整机CPU、GPU、POWER、TEMPERATURE、应用的FPS、RAM。
\ No newline at end of file
diff --git a/device/device_command/gp_utils.cpp b/device/device_command/gp_utils.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e2954eecb97db6600e0058601a4c598bc991a8df
--- /dev/null
+++ b/device/device_command/gp_utils.cpp
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include "securec.h"
+#include "include/gp_utils.h"
+
+namespace OHOS {
+ namespace SmartPerf {
+ void GPUtils::mSplit(const std::string &content, const std::string &sp, std::vector &out)
+ {
+ size_t index = 0;
+ while (index != std::string::npos) {
+ size_t t_end = content.find_first_of(sp, index);
+ std::string tmp = content.substr(index, t_end - index);
+ if (tmp != "" && tmp != " ") {
+ out.push_back(tmp);
+ }
+ if (t_end == std::string::npos) {
+ break;
+ }
+ index = t_end + 1;
+ }
+ }
+
+ bool GPUtils::canOpen(const std::string &path)
+ {
+ if (access(path.c_str(), F_OK) == -1) {
+ return false;
+ }
+ FILE *fp = fopen(path.c_str(), "r");
+ if (fp == nullptr) {
+ return false;
+ }
+ if (fclose(fp) == EOF) {
+ return false;
+ }
+ return true;
+ }
+
+ // popen
+ std::string GPUtils::readFile(const std::string &cmd)
+ {
+ const int buffLengh = 1024;
+ std::string res = "NA";
+ FILE *fp = popen(cmd.c_str(), "r");
+ char line[buffLengh];
+ line[0] = '\0';
+ while (fgets(line, buffLengh, fp) != nullptr) {
+ res = std::string(line);
+ }
+
+ if (pclose(fp) == EOF) {
+ return "";
+ }
+ return res;
+ }
+
+ // fopen
+ std::string GPUtils::freadFile(const std::string &path)
+ {
+ std::string res = "NA";
+ const int buffLengh = 1024;
+ if (access(path.c_str(), F_OK) == -1) {
+ return res;
+ }
+ FILE *fp;
+ if ((fp = fopen(path.c_str(), "r")) != nullptr) {
+ char s[buffLengh];
+ s[0] = '\0';
+ while (fgets(s, sizeof(s), fp) != nullptr) {
+ res += std::string(s);
+ }
+ }
+ if (fp != nullptr) {
+ fclose(fp);
+ }
+ return res;
+ }
+
+ // get number_str from str
+ std::string GPUtils::getNumber(const std::string &str)
+ {
+ int cntInt = 0;
+ const int shift = 10;
+
+ for (int i = 0; str[i] != '\0'; ++i) {
+ if (str[i] >= '0' && str[i] <= '9') {
+ cntInt *= shift;
+ cntInt += str[i] - '0';
+ }
+ }
+ return std::to_string(cntInt);
+ }
+
+ // wirte to csv by path
+ void GPUtils::writeCsv(const std::string &path, std::vector &vmap)
+ {
+ std::ofstream outFile;
+ char realPath[PATH_MAX + 1] = {0x00};
+ if (strlen(path.c_str()) > PATH_MAX || realpath(path.c_str(), realPath) == NULL) {
+ return;
+ }
+
+ outFile.open(path.c_str(), std::ios::out);
+ int i = 0;
+ std::string title = "";
+ for (GPData gpdata : vmap) {
+ std::map::iterator iter;
+ std::string line_content = "";
+ for (iter = gpdata.values.begin(); iter != gpdata.values.end(); ++iter) {
+ if (i == 0) {
+ title += iter->first + ",";
+ }
+ line_content += iter->second + ",";
+ }
+ if (i == 0) {
+ title.pop_back();
+ outFile << title << std::endl;
+ }
+ line_content.pop_back();
+ outFile << line_content << std::endl;
+ ++i;
+ }
+ outFile.close();
+ }
+ }
+}
diff --git a/device/device_command/include/gp_constant.h b/device/device_command/include/gp_constant.h
new file mode 100644
index 0000000000000000000000000000000000000000..ca085571336dd8a7066607a2cd617b14f9c6d145
--- /dev/null
+++ b/device/device_command/include/gp_constant.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef GP_CONSTANT_H
+#define GP_CONSTANT_H
+enum NumberConstant {
+ ZERO = 0X00,
+ ONE = 0X01,
+ TWO = 0X02,
+ THREE = 0X03
+};
+enum FunConstant {
+ SUCCESS_ONE = 0X01,
+ SUCCESS_ZERO = 0X00,
+ ERROR_ZERO = 0X00,
+ ERROR_MINUX = 0xFFFFFFFF
+};
+#endif
\ No newline at end of file
diff --git a/device/device_command/include/gp_data.h b/device/device_command/include/gp_data.h
new file mode 100644
index 0000000000000000000000000000000000000000..05c939bfe63cacdf68dac7b9813d88cfac2ca375
--- /dev/null
+++ b/device/device_command/include/gp_data.h
@@ -0,0 +1,23 @@
+/*
+* Copyright (C) 2021 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#ifndef GPDATA_H
+#define GPDATA_H
+#include