1# SmartPerf User Guide
2
3## Introduction
4
5SmartPerf Device is a reliable, easy-to-use performance and power consumption test tool. In this tool, you can monitor the performance and power consumption of your application and device with quantitative indicators, such as FPS, CPU, GPU, RAM, and Temp.
6
7<!--Del-->Targeted at devices with or without screens, SmartPerf Device provides two modes: Device-hap and Device-daemon. Device-hap is applicable to devices with screens and provides a visualized, intuitive UI that simplifies your operations. You can start and pause a test with a floating window, view performance data in real time, and save the test results for further analysis. <!--DelEnd-->Device-daemon is applicable to devices with and without screens and works with shell commands.
8
9### The following are the available indicators:
10
11- CPU: The tool reads the frequencies and usage of CPU cores on the test device on a per second basis to measure the CPU usage of the target application. Sustained high CPU may lead to overheating.
12- GPU: The tool reads the GPU frequency and load information of the test device on a per second basis to measure the GPU usage of the target application. High GPU usage can lead to performance drops and application slowdowns.
13- FPS: The tool reads the frame rate, in frames per second (FPS), of the target application to measure the smoothness of the application image. A higher FPS generally means smoother visuals.
14- TEMP: The tool reads the temperature information of the test device on a per second basis, including the GPU temperature and system chip temperature.
15- RAM: The tool reads the RAM usage of the target application on a per second basis.
16- snapshot: The tool takes a screenshot of the application UI every 2 seconds.
17
18## Principles
19
20The figure below demonstrates the main functions of SmartPerf Device. Set data collection items and parameters on Device-hap, start the application, and then send data requests for KPIs (such as FPS, RAM, and Trace) from Device-hap to Device-daemon through messages. Device-daemon collects, persists, and analyzes data as requested<!--Del-->, and then sends the data to Device-hap for display<!--DelEnd-->.
21
22![SmartPerf](figures/SmartPerfStru.png)
23
24## Constraints
25
261. Device-daemon and <!--Del-->Device-hap<!--DelEnd--> are pre-installed since API version 9.
27
282. Device-daemon must be connected to a hardware device<!--Del-->, and Device-hap can only be used on devices with a screen<!--DelEnd-->.
29
303. Before using the Device-Daemon, configure the [HDC environment](https://gitee.com/openharmony/developtools_hdc).
31
32<!--Del-->
33
34## SmartPerf Device-hap
35
36The RK3568 development board is used as an example below.
37
38### Obtaining the Application List
39
40Start SmartPerf Device-hap. On the home screen, click **Select an app**.
41
42![SmartPerfConfig1](figures/SmartPerfConfig1.png)
43![SmartPerfConfig2](figures/SmartPerfConfig2.png)
44![SmartPerfConfig3](figures/SmartPerfConfig3.png)
45
46### Setting Collection Parameters
47
48After the target application is selected, return to the start page and set the test indicators. You can also change the test name (which includes the name of the target application and the test time and will be displayed in the report), and specify whether to capture traces and whether to enable the screenshot feature. When you are done, click the **Start** button at the bottom.
49
50### Using the Floating Window to Manage Data Collection.
51
52To start collection, touch **Start** in the floating window. To pause, touch the timer in the floating window. 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.<br>You can drag the floating window to anywhere you like.
53
54![SmartPerfControl1](figures/SmartPerfControl1.png)
55![SmartPerfControl2](figures/SmartPerfControl2.png)
56
57### Viewing the Report
58
59Click **Report** to access the report list. Touch a report to view its details.
60
61![SmartPerfReport1](figures/SmartPerfReport1.png)
62![SmartPerfReport2](figures/SmartPerfReport2.png)
63<!--DelEnd-->
64
65<!--RP1-->
66## SmartPerf Device-daemon
67<!--RP1End-->
68
69### Collection Prerequisites
70
71#### Switch to shell.
72
73  ```
74  C:\Users\issusser>hdc shell
75  #
76  ```
77
78#### Start and view the daemon process.
79
80  ```
81  C:\Users\issusser>hdc shell
82  // Start the daemon process.
83  # SP_daemon
84  // Check whether the daemon process is running.
85  # ps -ef | grep SP_daemon
86  root          1584     1 0 21:50:05 ?     00:00:00 SP_daemon
87  root          1595  1574 3 21:51:02 pts/0 00:00:00 grep SP_daemon
88  #
89  ```
90
91#### View the help information.
92
93<!--RP3-->
94
95  ```
96  # SP_daemon --help
97  OpenHarmony performance testing tool SmartPerf command-line version
98   Usage: SP_daemon [options] [arguments]
99
100   options:
101    -N              set the collection times(default value is 0) range[1,2147483647], for example: -N 10
102    -PKG            set package name, must add, for example: -PKG ohos.samples.ecg
103    -c              get device CPU frequency and CPU usage, process CPU usage and CPU load ..
104    -g              get device GPU frequency and GPU load
105    -f              get app refresh fps(frames per second) and fps jitters and refreshrate
106    -profilerfps    get refresh fps and timestamp
107    -sections       set collection time period(using with profilerfps)
108    -t              get remaining battery power and temperature..
109    -p              get battery power consumption and voltage(Not supported by some devices)
110    -r              get process memory and total memory
111    -snapshot       get screen capture
112    -net            get uplink and downlink traffic
113    -start          collection start command
114    -stop           collection stop command
115    -VIEW           set layler, for example: -VIEW DisplayNode
116    -OUT            set csv output path.
117    -d              get device DDR information
118    -screen         get screen resolution
119    -deviceinfo     get device information
120    -server         start a process to listen to the socket message of the start and stop commands
121    -clear          clear the process ID
122    -ohtestfps      used by the validator to obtain the fps, the collection times can be set
123    -editorServer   start a process to listen to the socket message of the editor
124    -recordcapacity get the battery level difference
125    --version       get version
126    --help          get help
127    -editor         scenario-based collection identifier, parameter configuration items can be added later
128    responseTime   get the page response delay after an application is operated
129    completeTime   get the page completion delay after an application is operated
130    fpsohtest      used by the validator to obtain the fps
131    example1:
132    SP_daemon -N 20 -c -g -t -p -r -net -snapshot -d
133    SP_daemon -N 20 -PKG ohos.samples.ecg -c -g -t -p -f -r -net -snapshot -d
134    SP_daemon -start -c
135    SP_daemon -stop
136    example2: These parameters need to be used separately
137    SP_daemon -screen
138    SP_daemon -deviceinfo
139    SP_daemon -server
140    SP_daemon -clear
141    SP_daemon -ohtestfps 10
142    SP_daemon -editorServer
143    SP_daemon -recordcapacity
144    example3: These parameters need to be used separately
145    SP_daemon -editor responseTime ohos.samples.ecg app name
146    SP_daemon -editor completeTime ohos.samples.ecg app name
147    SP_daemon -editor fpsohtest
148
149
150
151    command exec finished!
152   #
153  ```
154<!--RP3End-->
155
156### Basic Collection
157
158#### Run the **-N** command to enable the collection
159
160| Command  |Mandatory| Description                  |
161| :-----| :-----| :--------------------- |
162| -N    |Yes| Sets the number of collection times (once per second).   |
163| -PKG  |No| Sets the bundle name.               |
164| -c    |No| Collects the CPU frequency and usage.<br>When the application bundle name is set, the system and application CPU information is collected.<br>Otherwise, only the system CPU information is collected.    |
165| -g    |No| Collects the GPU frequency and load information.  |
166| -f    |No| Collects the screen refresh rate and frame rate of the target application. The application bundle name must be specified.       |
167| -t    |No| Collects the temperature of the GPU and system chip.          |
168| -r    |No| Collects the memory.<br>When the application bundle name is set, the system and application memory information is obtained.<br>Otherwise, only the system memory information is obtained.            |
169| -snapshot |No| Takes screenshots.            |
170| -net |No| Collects the network speed.             |
171| -VIEW |No| Sets the view layer. You must obtain the layer name first.               |
172| -d    |No| Collects the DDR data.                |
173| -sections|No| Sets segment-based collection.         |
174<!--RP2--><!--RP2End-->
175
176##### Samples
177
178- Collect twice the frequency and usage of CPU cores.
179
180  ```
181    # SP_daemon -N 2 -c
182
183    order:0 timestamp=1503078645909
184    order:1 cpu0Frequency=1992000
185    order:2 cpu0Usage=34.042553
186    order:3 cpu0idleUsage=65.957447
187    order:4 cpu0ioWaitUsage=0.000000
188    order:5 cpu0irqUsage=0.000000
189    order:6 cpu0niceUsage=0.000000
190    order:7 cpu0softIrqUsage=0.000000
191    order:8 cpu0systemUsage=15.957447
192    order:9 cpu0userUsage=18.085106
193    order:10 cpu1Frequency=1992000
194    order:11 cpu1Usage=43.877551
195    order:12 cpu1idleUsage=56.122449
196    order:13 cpu1ioWaitUsage=0.000000
197    order:14 cpu1irqUsage=0.000000
198    order:15 cpu1niceUsage=0.000000
199    order:16 cpu1softIrqUsage=0.000000
200    order:17 cpu1systemUsage=17.346939
201    order:18 cpu1userUsage=26.530612
202    order:19 cpu2Frequency=1992000
203    order:20 cpu2Usage=38.043478
204    order:21 cpu2idleUsage=61.956522
205    order:22 cpu2ioWaitUsage=0.000000
206    order:23 cpu2irqUsage=0.000000
207    order:24 cpu2niceUsage=0.000000
208    order:25 cpu2softIrqUsage=0.000000
209    order:26 cpu2systemUsage=11.956522
210    order:27 cpu2userUsage=26.086957
211    order:28 cpu3Frequency=1992000
212    order:29 cpu3Usage=68.421053
213    order:30 cpu3idleUsage=31.578947
214    order:31 cpu3ioWaitUsage=0.000000
215    order:32 cpu3irqUsage=0.000000
216    order:33 cpu3niceUsage=0.000000
217    order:34 cpu3softIrqUsage=0.000000
218    order:35 cpu3systemUsage=13.684211
219    order:36 cpu3userUsage=54.736842
220
221    ...
222
223    command exec finished!
224    #
225  ```
226
227- Collect twice the frequency and usage of CPU cores and CPU usage and load of processes.
228
229  ```
230    # SP_daemon -N 2 -PKG com.ohos.settings -c
231
232
233
234    order:0 timestamp=1503078694916
235    order:1 ProcAppName=com.ohos.settings
236    order:2 ProcCpuLoad=0
237    order:3 ProcCpuUsage=0
238    order:4 ProcId=0
239    order:5 ProcSCpuUsage=0
240    order:6 ProcUCpuUsage=0
241    order:7 cpu0Frequency=1992000
242    order:8 cpu0Usage=31.868132
243    order:9 cpu0idleUsage=68.131868
244    order:10 cpu0ioWaitUsage=0.000000
245    order:11 cpu0irqUsage=0.000000
246    order:12 cpu0niceUsage=0.000000
247    order:13 cpu0softIrqUsage=0.000000
248    order:14 cpu0systemUsage=15.384615
249    order:15 cpu0userUsage=16.483516
250    order:16 cpu1Frequency=1992000
251    order:17 cpu1Usage=44.791667
252    order:18 cpu1idleUsage=55.208333
253    order:19 cpu1ioWaitUsage=0.000000
254    order:20 cpu1irqUsage=0.000000
255    order:21 cpu1niceUsage=0.000000
256    order:22 cpu1softIrqUsage=0.000000
257    order:23 cpu1systemUsage=13.541667
258    order:24 cpu1userUsage=31.250000
259    order:25 cpu2Frequency=1992000
260    order:26 cpu2Usage=37.894737
261    order:27 cpu2idleUsage=62.105263
262    order:28 cpu2ioWaitUsage=0.000000
263    order:29 cpu2irqUsage=0.000000
264    order:30 cpu2niceUsage=0.000000
265    order:31 cpu2softIrqUsage=1.052632
266    order:32 cpu2systemUsage=13.684211
267    order:33 cpu2userUsage=23.157895
268    order:34 cpu3Frequency=1992000
269    order:35 cpu3Usage=81.632653
270    order:36 cpu3idleUsage=18.367347
271    order:37 cpu3ioWaitUsage=0.000000
272    order:38 cpu3irqUsage=0.000000
273    order:39 cpu3niceUsage=0.000000
274    order:40 cpu3softIrqUsage=0.000000
275    order:41 cpu3systemUsage=15.306122
276    order:42 cpu3userUsage=66.326531
277
278    ...
279
280    command exec finished!
281    #
282  ```
283
284  >**NOTE**
285  >
286  >- Make sure you are on the application screen when running this command.
287
288- Collect once the GPU frequency and load of the system.
289
290  ```
291    # SP_daemon -N 1 -g
292
293
294
295    order:0 timestamp=1503078740268
296    order:1 gpuFrequency=200000000
297    order:2 gpuLoad=38.000000
298
299    command exec finished!
300    #
301  ```
302
303- Collect twice the system temperature.
304
305  ```
306    # SP_daemon -N 2 -t
307
308    order:0 timestamp=1502720711191
309    order:1 gpu-thermal=42500.000000
310    order:2 soc-thermal=43.125000
311
312
313    order:0 timestamp=1502720712191
314    order:1 gpu-thermal=41875.000000
315    order:2 soc-thermal=42.500000
316
317    command exec finished!
318    #
319  ```
320
321- Collect twice the memory information of the system.
322
323  ```
324    # SP_daemon -N 2 -r
325    order:0 timestamp=1705041562521
326    order:1 memAvailable=7339224
327    order:2 memFree=7164708
328    order:3 memTotal=11641840
329
330    order:0 timestamp=1705041563527
331    order:1 memAvailable=7339136
332    order:2 memFree=7164684
333    order:3 memTotal=11641840
334
335    command exec finished!
336    #
337  ```
338
339- Collect the memory information of the system and a specified application once.
340
341  ```
342    # SP_daemon -N 1 -PKG ohos.samples.ecg -r
343
344    order:0 timestamp=1720427095197
345    order:1 arktsHeapPss=17555
346    order:2 gpuPss=7021
347    order:3 graphicPss=163320
348    order:4 heapAlloc=120344
349    order:5 heapFree=14362
350    order:6 heapSize=133436
351    order:7 memAvailable=2757504
352    order:8 memFree=190852
353    order:9 memTotal=11742716
354    order:10 nativeHeapPss=49102
355    order:11 privateClean=1100020
356    order:12 privateDirty=175169
357    order:13 pss=422172
358    order:14 sharedClean=89348
359    order:15 sharedDirty=19084
360    order:16 stackPss=1588
361    order:17 swap=122076
362    order:18 swapPss=122076
363
364
365    command exec finished!
366    #
367  ```
368  >**NOTE**
369  >
370  >- Make sure you are on the application screen when running this command.
371  >- This command integrates the **-m** command of earlier version, which obtains data such as **arktsHeapPss**, **gpuPss**, **graphicPss**.
372
373- Take two screenshots.
374
375  ```
376    # SP_daemon -N 2 -snapshot
377
378    order:0 timestamp=1705041753321
379    order:1 capture=data/local/tmp/capture/screenCap_1705041753321.png
380
381    /data/local/tmp/capture created!
382
383    order:0 timestamp=1705041754324
384    order:1 capture=NA
385
386    command exec finished!
387    #
388  ```
389  >**NOTE**
390  >
391  >- Screenshots are collected every 2 seconds.
392  >
393  >-
394  >
395  >- When the collection is complete, you can view the screenshots in **data/local/tmp/capture**.
396  >
397  >- To export the screenshots to drive D, open a new CLI and run the **hdc file recv data/local/tmp/capture/screenCap_1700725192774.png D:\** command.
398
399- Collect the network speeds twice.
400
401  ```
402    # SP_daemon -N 2 -net
403
404    order:0 timestamp=1705041904832
405    order:1 networkDown=0
406    order:2 networkUp=0
407
408    order:0 timestamp=1705041905870
409    order:1 networkDown=22931
410    order:2 networkUp=2004
411
412    command exec finished!
413    #
414  ```
415
416- Collect the frame rate of the target application five times.
417
418  ```
419    # SP_daemon -N 5 -PKG ohos.samples.ecg -f
420
421    order:0 timestamp=1705306472232
422    order:1 fps=43
423    order:2 fpsJitters=602261688;;8352083;;8267708;;8305209;;8298437;;8308854;;8313542;;8569271;;8061458;;8300521;;8308333;;8309896;;8429167;;8241667;;8258333;;8318229;;8312500;;8304167;;41760937;;16418750;;8298959;;8319270;;8308334;;8313541;;8302605;;8320312;;8298958;;8326042;;8321354;;8301042;;8310417;;8309895;;8308855;;8331250;;8286458;;8343229;;8278125;;8311458;;8306250;;8312500;;8320834;;8346875;;8283333
424    order:3 refreshrate=120
425
426    order:0 timestamp=1705306473234
427    order:1 fps=40
428    order:2 fpsJitters=674427313;;8191145;;8310417;;8319271;;8301562;;8318750;;8302084;;8314062;;8333334;;8283854;;8307812;;8311979;;8310417;;8307813;;8309375;;8323958;;8306250;;8308333;;8317709;;8296875;;8721875;;7895833;;8320833;;8340625;;8276563;;8409896;;8216145;;8310938;;8301042;;8362500;;8252604;;8317708;;8376042;;8256250;;8292187;;8303125;;8313542;;8310417;;8520312
429    order:3 refreshrate=120
430    ...
431
432    command exec finished!
433    #
434  ```
435  >**NOTE**
436  >
437  >- When running this command, make sure you are on the application screen, and then swipe on the screen or switch between screens.
438  >- When dynamic refresh rate (DRR) is enabled, the refresh rate changes in real time (multiple changes may occur within one second). The value of **refreshrate** is collected at a timestamp.
439
440
441- Collect the frame rate of the specified view layer for 10 times.
442
443  ```
444    # SP_daemon -N 10 -VIEW DisplayNode -f
445    order:0 timestamp=1705306822850
446    order:1 fps=15
447    order:2 fpsJitters=876291843;;8314062;;8308334;;8314583;;8310417;;8308333;;8326042;;8314583;;8292708;;8492709;;8143750;;8340104;;8294271;;8302604;;8297396
448    order:3 refreshrate=120
449
450    order:0 timestamp=1705306823852
451    order:1 fps=12
452    order:2 fpsJitters=906667363;;8279167;;8311458;;8315625;;8291146;;8313021;;8323438;;8293750;;8303125;;8313541;;8301563;;8317708
453    order:3 refreshrate=120
454    ...
455
456    command exec finished!
457    #
458  ```
459  >**NOTE**
460  >
461  >- **DisplayNode** indicates the name of the specified layer.
462  >
463  >- When using this command to collect data, you need to operate the page on the specified layer.
464  >
465  >- This command cannot be used together with the commands used to collect frame rate of a specified application, such as the **SP_daemon -N 20 -PKG ohos.samples.ecg -f** or **SP_daemon -N 20 -VIEW DisplayNode -f** commands.
466
467- Collect DDR information once.
468
469  ```
470    # SP_daemon -N 1 -d
471
472    order:0 timestamp=1710916175201
473    order:1 ddrFrequency=1531000000
474
475    command exec finished!
476    #
477  ```
478<!--RP4--><!--RP4End-->
479
480- Collect the full information of the system, including the CPU, GPU, temperature, memory, DDR, network speed, and screenshot information.
481
482  ```
483    # SP_daemon -N 10 -c -g -t -r -d -net -snapshot
484
485    order:0 timestamp=1502725274844
486    order:1 cpu0Frequency=1992000
487    order:2 cpu0Usage=37.634409
488    order:3 cpu0idleUsage=62.365591
489    order:4 cpu0ioWaitUsage=0.000000
490    order:5 cpu0irqUsage=0.000000
491    order:7 cpu0softIrqUsage=1.075269
492    order:8 cpu0systemUsage=17.204301
493    order:9 cpu0userUsage=19.354839
494    order:10 cpu1Frequency=1992000
495    order:11 cpu1Usage=87.878788
496    order:12 cpu1idleUsage=12.121212
497    order:13 cpu1ioWaitUsage=0.000000
498    order:14 cpu1irqUsage=0.000000
499    order:15 cpu1niceUsage=0.000000
500    order:16 cpu1softIrqUsage=0.000000
501    order:17 cpu1systemUsage=15.151515
502    order:18 cpu1userUsage=72.727273
503    order:19 cpu2Frequency=1992000
504    order:20 cpu2Usage=45.544554
505    order:21 cpu2idleUsage=54.455446
506    order:22 cpu2ioWaitUsage=0.000000
507    order:23 cpu2irqUsage=0.000000
508    order:24 cpu2niceUsage=0.000000
509    order:25 cpu2softIrqUsage=0.990099
510    order:26 cpu2systemUsage=14.851485
511    order:27 cpu2userUsage=29.702970
512    order:28 cpu3Frequency=1992000
513    order:29 cpu3Usage=39.175258
514    order:30 cpu3idleUsage=60.824742
515    order:31 cpu3ioWaitUsage=0.000000
516    order:32 cpu3irqUsage=0.000000
517    order:33 cpu3niceUsage=0.000000
518    order:34 cpu3softIrqUsage=1.030928
519    order:35 cpu3systemUsage=14.432990
520    order:36 cpu3userUsage=23.711340
521    order:37 gpuFrequency=300000000
522    order:38 gpuLoad=25.000000
523    order:39 gpu-thermal=43750.000000
524    order:40 soc-thermal=45.555000
525    order:41 memAvailable=1118792
526    order:42 memFree=688032
527    order:43 memTotal=1990104
528    order:44 ddrFrequency=0
529    order:45 networkDown=0
530    order:46 networkUp=0
531    order:47 capture=data/local/tmp/capture/screenCap_1502725274893.png
532
533    ...
534
535    command exec finished!
536    #
537  ```
538
539- Collect the full information of the specified application, including the CPU, GPU, temperature, frame rate, memory, DDR, network speed, and screenshot information.
540
541  <!--RP5-->
542  ```
543    # SP_daemon -N 10 -PKG ohos.samples.ecg -c -g -t -f -r -d -net -snapshot
544
545    order:0 timestamp=1502725340425
546    order:1 ProcAppName=com.ohos.settings
547    order:2 ProcCpuLoad=0.000000
548    order:3 ProcCpuUsage=35.950135
549    order:4 ProcId=3912
550    order:5 ProcSCpuUsage=6.721698
551    order:6 ProcUCpuUsage=29.228437
552    order:7 cpu0Frequency=1992000
553    order:8 cpu0Usage=64.539007
554    order:9 cpu0idleUsage=35.460993
555    order:10 cpu0ioWaitUsage=0.000000
556    order:11 cpu0irqUsage=0.000000
557    order:12 cpu0niceUsage=0.000000
558    order:13 cpu0softIrqUsage=0.000000
559    order:14 cpu0systemUsage=26.241135
560    order:15 cpu0userUsage=38.297872
561    order:16 cpu1Frequency=1992000
562    order:17 cpu1Usage=73.758865
563    order:18 cpu1idleUsage=26.241135
564    order:19 cpu1ioWaitUsage=0.000000
565    order:20 cpu1irqUsage=0.000000
566    order:21 cpu1niceUsage=0.000000
567    order:22 cpu1softIrqUsage=0.000000
568    order:23 cpu1systemUsage=29.078014
569    order:24 cpu1userUsage=44.680851
570    order:25 cpu2Frequency=1992000
571    order:26 cpu2Usage=75.172414
572    order:27 cpu2idleUsage=24.827586
573    order:28 cpu2ioWaitUsage=0.000000
574    order:29 cpu2irqUsage=0.000000
575    order:30 cpu2niceUsage=0.000000
576    order:31 cpu2softIrqUsage=0.000000
577    order:32 cpu2systemUsage=18.620690
578    order:33 cpu2userUsage=56.551724
579    order:34 cpu3Frequency=1992000
580    order:35 cpu3Usage=80.419580
581    order:36 cpu3idleUsage=19.580420
582    order:37 cpu3ioWaitUsage=0.000000
583    order:38 cpu3irqUsage=0.000000
584    order:39 cpu3niceUsage=0.000000
585    order:40 cpu3softIrqUsage=0.699301
586    order:41 cpu3systemUsage=21.678322
587    order:42 cpu3userUsage=58.041958
588    order:43 gpuFrequency=800000000
589    order:44 gpuLoad=45.000000
590    order:45 gpu-thermal=44375.000000
591    order:46 soc-thermal=46.111000
592    order:47 fps=40
593    order:48 fpsJitters=14482127;;28966003;;28971836;;14484751;;28952878;;28970962;;14480959;;28968337;;14476001;;28967461;;28968045;;14477751;;28966878;;28975337;;14475126;;28962795;;28967461;;14496710;;28953169;;28966003;;14483002;;28963961;;28965711;;28964836;;28966295;;14550085;;28898628;;28964544;;28975628;;14497293;;28938878;;43454546;;28966003;;28973295;;28959878;;28964252;;14476585;;28965128;;28970670;;14478626
594    order:49 refreshrate=69
595    order:50 arktsHeapPss=8482
596    order:51 gpuPss=0
597    order:52 graphicPss=10800
598    order:53 heapAlloc=0
599    order:54 heapFree=0
600    order:55 heapSize=0
601    order:56 memAvailable=1113084
602    order:57 memFree=681968
603    order:58 memTotal=1990104
604    order:59 nativeHeapPss=24630
605    order:60 privateClean=7072
606    order:61 privateDirty=43304
607    order:62 pss=71001
608    order:63 sharedClean=93024
609    order:64 sharedDirty=45060
610    order:65 stackPss=1784
611    order:66 swap=0
612    order:67 swapPss=0
613    order:68 ddrFrequency=0
614    order:69 networkDown=0
615    order:70 networkUp=0
616    order:71 capture=data/local/tmp/capture/screenCap_1502725341222.png
617
618    ...
619
620    command exec finished!
621    #
622  ```
623  <!--RP5End-->
624
625  >**NOTE**
626  >
627  >- Make sure you are on the application screen when running this command.
628
629
630#### Run the **-start** command to start the collection
631
632Run the **start** command to start collection, operate the device or application, and then run the **stop** command to stop collection.
633
634| Command  |Mandatory| Description                  |
635| :-----|:-----| :--------------------- |
636| -start |Yes| Starts collection. You can add a basic collection command after this command parameter. The collection is performed every second.           |
637| -stop |Yes| Stops collection. A report is generated when collection is complete.             |
638
639##### Samples
640
641   ```
642   Start data collection.
643   # SP_daemon -start -c
644   SP_daemon Collection begins
645   command exec finished!
646   #
647
648   Stop data collection.
649   # SP_daemon -stop
650   SP_daemon Collection ended
651   Output Path: data/local/tmp/smartperf/1/t_index_info_csv
652   command exec finished!
653   #
654   ```
655   >**NOTE**
656   >
657   >- To start collecting the system data, run the **SP_daemon -start -c -g -t -r -d -net -snapshot** command.
658   >
659   >- To start collecting the system and process data, run the **SP_daemon -start -PKG ohos.samples.ecg -c -g -t -f -r -d -net -snapshot** command.
660   >
661   >- The service start and stop file is stored in **data/local/tmp/smartperf/1/t_index_info.csv**. You can run the **hdc file recv** command to export the report. For details, see [Viewing Collection Result in the CSV File](#viewing-collection-result-in-the-csv-file).
662
663#### Viewing Collection Result in the CSV File
664
665If the collection result is saved in a CSV file, perform the following steps to export and view the result:
666
667  - By default, the collection results are saved to **/data/local/tmp/data.csv**.
668
669  - To check the path to the test result file:
670
671    ```
672    C:\Users\issusser>hdc shell
673    # cd data/local/tmp
674    # ls
675    data.csv
676    #
677    ```
678
679  - To export the test result file:
680    ```
681    C:\Users\issusser>hdc file recv data/local/tmp/data.csv D:\
682    [I][2023-11-08 16:16:41] HdcFile::TransferSummary success
683    FileTransfer finish, Size:429, File count = 1, time:6ms rate:71.50kB/s
684
685    C:\Users\issusser>
686    ```
687
688  - Open the **data.csv** file to view the collected data.
689
690    The table below describes the data fields in the **data.csv** file.
691
692    | Data Field   | Description            |Remarks|
693    | :-----| :--------------------- |:-----|
694    | cpuFrequency      | CPU core frequency.       |Unit: Hz|
695    | cpuUasge          | CPU core usage.         |%|
696    | cpuidleUsage      | CPU usage in idle state.       |%|
697    | cpuioWaitUsage    | CPU usage of I/O wait.       |%|
698    | cpuirqUsage       | CPU usage of hardware interrupts.        |%|
699    | cpuniceUsage      | CPU usage of user level processes with lower scheduling priority.   |%|
700    | cpusoftIrqUsage   | CPU usage of software interrupts.        |%|
701    | cpusystemUsage    | CPU usage in kernel mode.     |%|
702    | cpuuserUsage      | CPU usage in user mode.          |%|
703    | ProcId            | PID.               |-|
704    | ProcAppName       | App package name.               |-|
705    | ProcCpuLoad       | Process CPU load.       |%|
706    | ProcCpuUsage      | CPU usage of the process.         |%|
707    | ProcUCpuUsage     | CPU usage of the process in user mode.    |%|
708    | ProcSCpuUsage     | CPU usage of the process in kernel mode.    |%|
709    | gpuFrequ          | GPU frequency of the system.         |%|
710    | gpuLoad           | GPU load of the system.     |%|
711    | currentNow        | Current value.      |Unit: mA|
712    | voltageNow        | Voltage value.      |Unit: μV|
713    | fps               | Number of frames per second.             |Unit: FPS|
714    | fpsJitters        | Frame interval.       |Unit: ns|
715    | refreshrate       | Screen refresh rate.           |Unit: Hz|
716    | networkDown       | Downstream rate.             |Unit: byte/s|
717    | networkUp         | Uplink rate.             |Unit: byte/s|
718    | ddrFrequency      | DDR frequency.              |Unit: Hz|
719    | gpu-thermal       | GPU temperature.             |Unit: °C|
720    | soc-thermal       | SoC temperature.         |Unit: °C|
721    | memAvailable      | Available memory of the system.        |Unit: KB|
722    | memFree           | Free memory of the system.        |Unit: KB|
723    | memTotal          | Total memory of the system.          |Unit: KB|
724    | pss               | Proportional set size (PSS) of the process.     |Unit: KB|
725    | sharedClean       | Shared unwritten pages.     |Unit: KB|
726    | sharedDirty       | Shared rewritten pages.     |Unit: KB|
727    | priviateClean     | Private unwritten pages.     |Unit: KB|
728    | privateDirty      | Private rewritten pages.     |Unit: KB|
729    | swapTotal         | Total swap memory.         |Unit: KB|
730    | swapPss           | Swapped PSS.       |Unit: KB|
731    | HeapSize          | Heap size.          |Unit: KB|
732    | HeapAlloc         | Heap size that can be allocated.   |Unit: KB|
733    | HeapFree          | Remaining heap size.     |Unit: KB|
734    | gpuPss            | Used GPU size.    |Unit: KB|
735    | graphicPss        | Used graphics memory size.    |Unit: KB|
736    | arktsHeapPss      | Used ArkTS memory size.   |Unit: KB|
737    | nativeHeapPss     | Used native memory size.  |Unit: KB|
738    | stackPss          | Used stack memory size.      |Unit: KB|
739    | timeStamp         | Timestamp.           |Collection time.|
740    <!--RP6--><!--RP6End-->
741
742### Scenario Collection
743
744<!--RP7-->
745
746In addition to basic collection, the response and completion delay can be collected. The scenario collection result is displayed in the CLI instead of being written into the **data.csv** file.
747
748| Command  |Mandatory| Description                  |
749| :-----|:-----| :--------------------- |
750| -editor|Yes|    Scenario collection tag, which can be followed by parameter configuration options.        |
751| -responseTime|No|    Response delay.        |
752| -completeTime|No|    Completion delay.        |
753| -fpsohtest|No|    A validator used to collect the frame rate every second. The frame rate is collected 10 times by default.      |
754
755#### Samples
756
757- Collect the application response delay.
758
759  ```
760   # SP_daemon -editor responseTime com.ohos.settings
761   time:544ms
762
763   command exec finished!
764  ```
765  >**NOTE**
766  >
767  >- Open the application before collection, press **Enter** in the CLI, switch to the application page, and wait for the collection result to be printed.
768
769- Collect the application completion delay.
770
771  ```
772   # SP_daemon -editor completeTime com.ohos.settings
773   time:677ms
774
775   command exec finished!
776  ```
777  >**NOTE**
778  >
779  >- Open the application before collection, press **Enter** in the CLI, switch to the application page, and wait for the collection result to be printed.
780
781- Use the validator to obtain the application page frame rate.
782
783  ```
784   # SP_daemon -editor fpsohtest
785   set num:10 successfps:0|1726909713442fps:97|1726909714442fps:113|1726909715442fps:116|1726909716442fps:116|1726909717442fps:118|1726909718442fps:114|1726909719442fps:114|1726909720442fps:115|1726909721442fps:118|1726909722442SP_daemon exec finished!
786  ```
787  >**NOTE**
788  >
789  >- You need to swipe or switch the current page after running the command, and the collection result will be printed after 10s.
790
791<!--RP7End-->
792
793### Other Collection
794
795The power collection result of the current device can be written into the **data.csv** file. Other data is collected separately and the collection result is displayed only in the command box.
796
797| Command  |Mandatory| Description                  |
798| :-----|:-----| :--------------------- |
799| -screen |No| Collects the screen resolution and refresh rate.              |
800| -deviceinfo|No| Obtains device information.             |
801| -server|No|    Starts a daemon process by starting or stopping collection.          |
802| -clear|No|    Clears all the SP_daemon processes.          |
803| -ohtestfps|No|    Obtains the frame rate. The number of collection times can be set (collection is performed every second).         |
804| -editorServer|No|    Starts a daemon process by using an editor.        |
805| -recordcapacity|No|    Obtains the battery level of the current device.        |
806| -profilerfps |No| Collects the frame rate of the current page.         |
807
808#### Samples
809
810- Obtain the screen resolution.
811
812  ```
813   # SP_daemon -screen
814   activeMode: 1260x2720, refreshrate=120
815   command exec finished!
816   #
817  ```
818  >**NOTE**
819  >
820  >- **activeMode** indicates the current screen resolution, and **refreshrate** indicates the screen refresh rate.
821
822- Obtain the device information.
823
824  ```
825   # SP_daemon -deviceinfo
826   abilist: default
827   activeMode: 720x1280
828   board: hw
829   brand: default
830   cpu_c1_cluster: 0 1 2 3
831   cpu_c1_max: 1992000
832   cpu_c1_min: 408000
833   cpu_cluster_name: policy0
834   deviceTypeName: rk3568
835   fullname: OpenHarmony-5.0.2.43
836   gpu_max_freq: 800000000
837   gpu_min_freq: 200000000
838   model: ohos
839   name: OpenHarmony 3.2
840   sn: 7001005458323933328a26dbb7bd3900
841   version: OpenHarmony 5.0.2.43
842
843   command exec finished!
844   #
845  ```
846
847- Start a process to listen for the socket messages of the **start** and **stop** commands.
848
849  ```
850   # SP_daemon -server
851   #
852   # pidof SP_daemon
853   7024
854   #
855
856   command exec finished!
857   #
858  ```
859  >**NOTE**
860  >
861  >- You can run the **pidof SP_daemon** command to view the process ID.
862
863- Clear the SP_daemon process ID.
864
865  ```
866   # pidof SP_daemon
867   9923 11402
868   # SP_daemon -clear
869   #
870   # pidof SP_daemon
871   #
872
873   command exec finished!
874   #
875  ```
876  >**NOTE**
877  >
878  >- You can run the **pidof SP_daemon** command to view the process ID.
879
880- Obtain the frame rate of the current page using a validator.
881
882  ```
883   # SP_daemon -ohtestfps 10
884   set num:10 success
885   fps:1|1501926684532
886   fps:18|1501926685532
887   fps:37|1501926686532
888   fps:41|1501926687532
889   fps:42|1501926688532
890   fps:16|1501926689532
891   fps:40|1501926690532
892   fps:40|1501926691532
893   fps:42|1501926692532
894   fps:41|1501926693532
895   SP_daemon exec finished!
896   #
897
898   command exec finished!
899   #
900  ```
901  >**NOTE**
902  >
903  >- In this command, **10** indicates the number of collection times (collection is performed every second). You can set it to a positive integer.
904
905
906- Start a process to listen for the socket messages of the editor tool.
907
908  ```
909   # SP_daemon -editorServer
910   Socket Process called!
911   Socket TCP Init called!
912   Socket Process called!
913   Socket Process called!
914915  ```
916
917
918- Obtain the battery level.
919
920  ```
921   # SP_daemon -recordcapacity
922   recordTime: 1726903063
923   recordPower: 5502
924  ```
925  >**NOTE**
926  >
927  >- **recordTime** indicates the timestamp, and **recordPower** indicates the current battery level.
928  >
929  >- This command needs to be executed separately. The collection result is written into the **/data/local/tmp/powerLeftRecord.csv** file and can be exported to the local PC by running the **hdc file recv** command. For details, see [Viewing Collection Result in the CSV File](#viewing-collection-result-in-the-csv-file).
930
931- Collect the frame rate of the current page.
932
933  ```
934    # SP_daemon -profilerfps 10
935    set num:10 success
936    fps:0|1711692357278
937    fps:0|1711692358278
938    fps:1|1711692359278
939    fps:0|1711692360278
940    fps:0|1711692361278
941    fps:0|1711692362278
942    fps:0|1711692363278
943    fps:0|1711692364278
944    fps:26|1711692365278
945    fps:53|1711692366278
946    SP_daemon exec finished!
947    #
948  ```
949  >**NOTE**
950  >
951  >- In this command, **100** indicates the number of collection times (collection is performed every second). You can set it to a positive integer.
952
953- Collect the frame rate by time segment.
954
955  ```
956    # SP_daemon -profilerfps 100 -sections 10
957    set num:100 success
958    fps:0|1711692393278
959    fps:0|1711692394278
960    fps:0|1711692395278
961    fps:44|1711692396278
962    sectionsFps:0|1711692396278
963    sectionsFps:0|1711692396378
964    sectionsFps:40|1711692396478
965    sectionsFps:60|1711692396578
966    sectionsFps:60|1711692396678
967    sectionsFps:60|1711692396778
968    sectionsFps:60|1711692396878
969    sectionsFps:40|1711692396978
970    sectionsFps:60|1711692397078
971    sectionsFps:60|1711692397178
972    fps:51|1711692397278
973
974    ...
975
976    SP_daemon exec finished!
977    #
978  ```
979  >**NOTE**
980  >
981  >- In this command, **100** indicates the number of collection times (collection is performed every second) and can be set to a positive integer. **10** indicates collection by segment. Currently, the number of collection segments can be set to a positive integer ranging from 1 to 10.
982