smartperf-guidelines.md 3.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
# SmartPerf User Guide

## Overview

Performance testing helps developers detect the performance bottlenecks and deliver quality applications that meet user expectations. For this reason, SmartPerf, a performance testing tool specially designed for OpenHarmony developers, is provided.

## Introduction

SmartPerf is a reliable, easy-to-use performance and power consumption test tool built for the OpenHarmony system. It provides KPIs with test value details that help you measure the performance and power consumption of your application, such as FPS, CPU, GPU, and Ftrace.

You can use SmartPerf in two modes: visualized operation mode (SmartPerf-Device) and command-line shell mode (SmartPerf-Daemon). SmartPerf-Device supports visualized operations and floating window based operations (such as data collection control and real-time data display). SmartPerf-Daemon is applicable to devices without screens and devices with high tolerance regarding performance, for example, Hi3568.

## Principles

SmartPerf come with SmartPerf-Device and SmartPerf-Daemon. SmartPerf-Device sends data requests for KPIs (such as FPS, RAM, and Trace) through messages to SmartPerf-Daemon, which then collects and sends back data as requested, and displays the received data. SmartPerf-Daemon also allows on-demand data collection through hell commands. The figure below demonstrates the main functions of SmartPerf.

![SmartPerf](figures/SmartPerfStru.png)

## Constraints

- SmartPerf-Device and SmartPerf-Daemon are pre-installed in version 3.2 and later versions.
- SmartPerf-Device requires a screen to work correctly.

## Environment Preparations

To run SmartPerf-Daemon, you must connect the PC to an OpenHarmony device, such as the RK3568 development board.

## Performing Performance Testing

**Using SmartPerf-Device**

In the screenshots below, the RK3568 development board is used as an example.

1. Set the application for which you want to collect data.

   Start SmartPerf-Device. On the home screen, select the test application and test indicators, and touch **Start Test**.

2. Control the data collection process from the floating window.

   To start collection, touch **Start** in the floating window. To pause, touch the timer in the floating window to pause data collection. To resume, touch the timer again. To view the collected data in real time, double-touch the timer. To stop, touch and hold the timer. You can drag the floating window to anywhere you like.


3. View the report.

   Touch **Report** to view the test report list. Touch **Report List** to view details about test indicators.

**Using SmartPerf-Daemon**

1. Access the shell and run the following command to view the help information:
```
:# SP_daemon --help
```
2. Run the collection commands.
```
:# SP_daemon -N 2 -PKG com.ohos.contacts -c -g -t -p -r
```

**Collection Commands**

| Command  | Function                  |Mandatory|
| :-----| :--------------------- |:-----|
| -N    | Set the number of collection times.            |Yes|
| -PKG  | Set the package name.               | No|
| -PID  | Sets the PID of a process (applicable to RAM).|No|
| -c    | Set whether to collect CPU data.            | No|
| -g    | Set whether to collect GPU data.            |No|
| -f    | Set whether to collect FPS data.            |No|
| -t    | Set whether to collect temperature data.            |No|
| -p    | Set whether to collect current data.            |No|
| -r    | Set whether to collect memory data.            |No|

The default output path of the test result is as follows:
```
/data/local/tmp/data.csv
```