1# SmartPerf User Guide 2 3## Introduction 4 5SmartPerf is a reliable, easy-to-use performance and power consumption test tool. In this tool, you can measure the performance and power consumption of your application with quantitative indicators, such as FPS, CPU, GPU, RAM, and Temp. 6 7Targeted at devices with or without screens, SmartPerf provides two modes: SmartPerf-Device and SmartPerf-Daemon. 8 9- SmartPerf-Device 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. 10- SmartPerf-Daemon is applicable to devices with and without screens and works with shell commands. 11 12The following are the available indicators: 13 14- 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. 15- 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. 16- 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. 17- POWER: The tool reads the current and voltage of the test device on a per second basis. 18- TEMP: The tool reads the temperature information of the test device on a per second basis, including the battery temperature and system chip temperature. 19- RAM: The tool reads the RAM usage of the target application on a per second basis. 20- snapshot: The tool takes a screenshot of the application UI every second. 21 22## Principles 23 24The figure below demonstrates the main functions of SmartPerf. Set data collection items and parameters on SmartPerf-Device, start the application, and then send data requests for KPIs (such as FPS, RAM, and Trace) from SmartPerf-Device to SmartPerf-Daemon through messages. SmartPerf-Daemon collects, persists, and analyzes data as requested, and then sends the data to SmartPerf-Device for display. 25 26 27 28## Constraints 29 301. SmartPerf-Device and SmartPerf-Daemon are pre-installed since API version 9. 31 322. SmartPerf-Device can only be used on devices with a screen, and SmartPerf-Daemon must be connected to a hardware device. 33 343. Before using SmartPerf-Daemon, configure the [HDC environment](https://gitee.com/openharmony/developtools_hdc). 35 36## Performing Performance Testing 37 38### SmartPerf-Device 39 40The RK3568 development board is used as an example below. 41 421. Obtain the application list and select an application. 43 44Start SmartPerf-Device. On the home screen, select the target application. 45 462. Configure test settings. 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 503. Use 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 544. View test results. 55 56Click **Report** to access the report list. Touch a report to view its details. 57 58### SmartPerf-Daemon 59 60**Basic Collection Commands** 61 62| Command | Function |Mandatory| 63| :-----| :--------------------- |:-----| 64| -N | Sets the number of collection times (once per second).|Yes| 65| -PKG | Sets the bundle name. | No| 66| -c | Collects the CPU frequency and usage. If the application bundle name is set, the collected information covers both the system and the target application. If the application bundle name is not set, the collected information covers the system only. | No| 67| -g | Collects the GPU frequency and load information. |No| 68| -f | Collects the frame rate of the target application. The application bundle name must be specified. |No| 69| -profilerfps | Collects the frame rate of the current page. |No| 70| -t | Collects temperature information. |No| 71| -p | Collects current and voltage information. |No| 72| -r | Collects the RAM usage. If the application bundle name is set, the collected information covers both the system and the target application. If the application bundle name is not set, the collected information covers the system only. |No| 73| -snapshot | Takes screenshots. |No| 74| -net | Collects the network speed. |No| 75| -VIEW | Sets the view layer. You must obtain the layer name first. |No| 76| -screen | Collects the screen resolution and refresh rate. |No| 77 78**Commands for Starting or Stopping Data Collection** 79 80| Command | Function |Mandatory| 81| :-----| :--------------------- |:-----| 82| -start | Starts collection. This command can be followed by basic collection commands. |Yes| 83| -stop | Stops collection. A report is generated when collection is complete. |Yes| 84 85**Example** 86 871. Run the Win + R command to open the command-line interface (CLI). 88 89 ``` 90 C:\Users\issusser>hdc shell // Example 91 # 92 ``` 93 942. Start the daemon process. 95 96 ``` 97 C:\Users\issusser>hdc shell 98 # SP_daemon 99 # 100 ``` 101 1023. Check whether the daemon process is running. 103 104 ``` 105 C:\Users\issusser>hdc shell 106 # SP_daemon 107 # ps -ef | grep SP_daemon 108 root 1584 1 0 21:50:05 ? 00:00:00 SP_daemon 109 root 1595 1574 3 21:51:02 pts/0 00:00:00 grep SP_daemon 110 # 111 ``` 112 1134. View the help information. 114 115 ``` 116 # SP_daemon --help 117 usage: SP_daemon <options> <arguments> 118 -------------------------------------------------------------------- 119 These are common commands list: 120 -N set the collection times, for example: -N 10 121 -PKG set package name, must add, for example: -PKG ohos.samples.ecg 122 -c get device cpuFreq and cpuUsage, process cpuUsage and cpuLoad .. 123 -g get device gpuFreq and gpuLoad 124 -f get app refresh fps and fps jitters 125 -t get soc-temp gpu-temp .. 126 -p get current_now and voltage_now 127 -r get process memory and total memory .. 128 -snapshot get screen capture 129 -net get networkUp and networkDown 130 -start collection start command 131 -stop collection stop command 132 -VIEW set layer, for example: -VIEW DisplayNode 133 -profilerfps get refresh fps and timestamp 134 -screen get screen resolution 135 -------------------------------------------------------------------- 136 Example 1: SP_daemon -N 20 -c -g -t -p -r -net -snapshot 137 -------------------------------------------------------------------- 138 --------------------------------------------------------------------------------------- 139 Example 2: SP_daemon -N 20 -PKG ohos.samples.ecg -c -g -t -p -f -r -net -snapshot 140 --------------------------------------------------------------------------------------- 141 ------------------------------- 142 Example 3: SP_daemon -start -c 143 ------------------------------- 144 ------------------------------- 145 Example 4: SP_daemon -stop 146 ------------------------------- 147------------------------------- 148 Example 5: SP_daemon -screen 149 ------------------------------- 150 151 command exec finished! 152 # 153 ``` 154 1555. Run the collection commands. 156 157 5.1 Collect twice the frequency and usage of CPU cores. 158 159 ``` 160 # SP_daemon -N 2 -c 161 162 order:0 timestamp=1501923846459 163 order:1 cpu0Frequency=408000 164 order:2 cpu0Usage=7.142857 165 order:3 cpu0idleUsage=92.857143 166 order:4 cpu0ioWaitUsage=0.000000 167 order:5 cpu0irqUsage=0.000000 168 order:6 cpu0niceUsage=0.000000 169 order:7 cpu0softIrqUsage=0.000000 170 order:8 cpu0systemUsage=5.102041 171 order:9 cpu0userUsage=2.040816 172 ... 173 174 command exec finished! 175 # 176 ``` 177 178 5.2 Collect twice the frequency and usage of CPU cores and CPU usage and load of processes. 179 180 ``` 181 # SP_daemon -N 2 -PKG ohos.samples.ecg -c 182 183 order:0 timestamp=1705043036099 184 order:1 ProcAppName=ohos.samples.ecg 185 order:2 ProcCpuLoad=0.008766 186 order:3 ProcCpuUsage=0.025100 187 order:4 ProcId=8815 188 order:5 ProcSCpuUsage=0.000000 189 order:6 ProcUCpuUsage=0.025100 190 order:7 cpu0Frequency=1430000 191 order:8 cpu0Usage=29.032258 192 order:9 cpu0idleUsage=70.967742 193 order:10 cpu0ioWaitUsage=0.000000 194 order:11 cpu0irqUsage=2.150538 195 order:12 cpu0niceUsage=0.000000 196 order:13 cpu0softIrqUsage=0.000000 197 order:14 cpu0systemUsage=15.053763 198 order:15 cpu0userUsage=11.827957 199 ... 200 201 command exec finished! 202 # 203 ``` 204 >**NOTE** 205 > 206 >- Make sure you are on the application screen when running this command. 207 208 5.3 Collect once the GPU frequency and load of the system. 209 210 ``` 211 # SP_daemon -N 1 -g 212 213 order:0 timestamp=1705041456507 214 order:1 gpuFrequency=279000000 215 order:2 gpuLoad=12.000000 216 217 command exec finished! 218 # 219 ``` 220 221 5.4 Collect twice the system temperature. 222 223 ``` 224 # SP_daemon -N 2 -t 225 226 order:0 timestamp=1705042469378 227 order:1 Battery=36.000000 228 order:2 shell_back=38.962000 229 order:3 shell_frame=37.962000 230 order:4 shell_front=42.663000 231 order:5 soc_thermal=48.645000 232 order:6 system_h=38.277000 233 234 order:0 timestamp=1705042470389 235 order:1 Battery=36.000000 236 order:2 shell_back=38.962000 237 order:3 shell_frame=37.962000 238 order:4 shell_front=42.663000 239 order:5 soc_thermal=48.486000 240 order:6 system_h=38.277000 241 242 command exec finished! 243 # 244 ``` 245 246 5.5 Collect once the current and voltage of the system. 247 248 ``` 249 # SP_daemon -N 1 -p 250 251 order:0 timestamp=1705041491090 252 order:1 currentNow=-255 253 order:2 voltageNow=4377614 254 255 command exec finished! 256 # 257 ``` 258 259 5.6 Collect twice the memory information of the system. 260 261 ``` 262 # SP_daemon -N 2 -r 263 order:0 timestamp=1705041562521 264 order:1 memAvailable=7339224 265 order:2 memFree=7164708 266 order:3 memTotal=11641840 267 268 order:0 timestamp=1705041563527 269 order:1 memAvailable=7339136 270 order:2 memFree=7164684 271 order:3 memTotal=11641840 272 273 command exec finished! 274 # 275 ``` 276 277 5.7 Collect twice the memory information of the system and the target application process. 278 279 ``` 280 # SP_daemon -N 2 -PKG ohos.samples.ecg -r 281 282 order:0 timestamp=1705041668525 283 order:1 memAvailable=7350856 284 order:2 memFree=7166896 285 order:3 memTotal=11641840 286 order:4 pss=107232 287 288 order:0 timestamp=1705041669527 289 order:1 memAvailable=7350852 290 order:2 memFree=7166896 291 order:3 memTotal=11641840 292 order:4 pss=107232 293 294 command exec finished! 295 # 296 ``` 297 >**NOTE** 298 > 299 >- Make sure you are on the application screen when running this command. 300 301 5.8 Take two screenshots. 302 303 ``` 304 # SP_daemon -N 2 -snapshot 305 306 order:0 timestamp=1705041753321 307 order:1 capture=data/local/tmp/capture/screenCap_1705041753321.png 308 309 /data/local/tmp/capture created! 310 311 order:0 timestamp=1705041754324 312 order:1 capture=data/local/tmp/capture/screenCap_1705041754324.png 313 314 command exec finished! 315 # 316 ``` 317 >**NOTE** 318 > 319 >- 320 > 321 >- When the collection is complete, you can view the screenshots in **data/local/tmp/capture**. 322 > 323 >- To export the screenshots to drive D, open a new CLI and run the **hdc file recv data/local/tmp/screenCap_1700725192774.png D:\** command. 324 325 5.9 Collect twice the network speeds. 326 327 ``` 328 # SP_daemon -N 2 -net 329 330 order:0 timestamp=1705041904832 331 order:1 networkDown=0 332 order:2 networkUp=0 333 334 order:0 timestamp=1705041905870 335 order:1 networkDown=22931 336 order:2 networkUp=2004 337 338 command exec finished! 339 # 340 ``` 341 342 5.10 Collect the frame rate of the target application five times. 343 344 ``` 345 # SP_daemon -N 5 -PKG ohos.samples.ecg -f 346 347 order:0 timestamp=1705306472232 348 order:1 fps=43 349 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 350 351 order:0 timestamp=1705306473234 352 order:1 fps=40 353 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;;8109375 354 ... 355 command exec finished! 356 # 357 ``` 358 >**NOTE** 359 > 360 >- When running this command, make sure you are on the application screen, and then swipe on the screen or switch between screens. 361 362 5.11 Collect the frame rate of the specified view layer of the target application for five times. 363 364 - Obtain the view layer name. 365 366 ``` 367 # hidumper -s 10 -a surface | grep surface 368 surface [DisplayNode] NodeId[6781753360410] LayerId[10]: 369 surface [RCDTopSurfaceNode] NodeId[6781753360412] LayerId[12]: 370 surface [RCDBottomSurfaceNode] NodeId[6781753360411] LayerId[11]: 371 # 372 ``` 373 374 - Collect the frame rate of the specified view layer. 375 376 ``` 377 # SP_daemon -N 10 -VIEW DisplayNode -f 378 order:0 timestamp=1705306822850 379 order:1 fps=15 380 order:2 fpsJitters=876291843;;8314062;;8308334;;8314583;;8310417;;8308333;;8326042;;8314583;;8292708;;8492709;;8143750;;8340104;;8294271;;8302604;;8297396 381 382 order:0 timestamp=1705306823852 383 order:1 fps=12 384 order:2 fpsJitters=906667363;;8279167;;8311458;;8315625;;8291146;;8313021;;8323438;;8293750;;8303125;;8313541;;8301563;;8317708 385 ... 386 # 387 ``` 388 >**NOTE** 389 > 390 >- Before running this command, you must obtain the application view layer name. 391 > 392 >- Replace *DisplayNode* following **-VIEW** with the obtained layer name. When running this command, make sure you are on the application screen, and then swipe on the screen or switch between screens. 393 394 5.12 Collect the full information of the system, including the CPU, GPU, temperature, current, screenshot, network speed, and memory information. 395 396 ``` 397 # SP_daemon -N 10 -c -g -t -p -snapshot -net -r 398 399 order:0 timestamp=1705042018276 400 order:1 cpu0Frequency=490000 401 order:2 cpu0Usage=33.000000 402 order:3 cpu0idleUsage=67.000000 403 order:4 cpu0ioWaitUsage=0.000000 404 order:5 cpu0irqUsage=1.000000 405 order:6 cpu0niceUsage=0.000000 406 order:7 cpu0softIrqUsage=0.000000 407 order:8 cpu0systemUsage=14.000000 408 order:9 cpu0userUsage=18.000000 409 ... 410 411 command exec finished! 412 # 413 ``` 414 415 5.13 Collect the full information of the target application, including the CPU, GPU, temperature, current, frame rate, screenshot, network speed, and memory information. 416 417 ``` 418 # SP_daemon -N 10 -PKG ohos.samples.ecg -c -g -t -p -f -snapshot -net -r 419 420 order:0 timestamp=1705307489445 421 order:1 ProcAppName=ohos.samples.ecg 422 order:2 ProcCpuLoad=0.000001 423 order:3 ProcCpuUsage=0.000000 424 order:4 ProcId=13131 425 order:5 ProcSCpuUsage=0.000000 426 order:6 ProcUCpuUsage=0.000000 427 order:7 cpu0Frequency=418000 428 order:8 cpu0Usage=27.884615 429 order:9 cpu0idleUsage=72.115385 430 order:10 cpu0ioWaitUsage=0.000000 431 order:11 cpu0irqUsage=0.961538 432 order:12 cpu0niceUsage=0.000000 433 order:13 cpu0softIrqUsage=0.000000 434 order:14 cpu0systemUsage=12.500000 435 order:15 cpu0userUsage=14.423077 436 ... 437 438 command exec finished! 439 # 440 ``` 441 442 5.14 Collect the frame rate of the current page. 443 444 ``` 445 # SP_daemon -profilerfps 10 446 set num:10 success 447 fps:82|1707125314494 448 fps:81|1707125534494 449 fps:114|1707125535494 450 fps:114|1707125536494 451 fps:115|1707125537494 452 fps:117|1707125538494 453 fps:112|1707125539494 454 fps:114|1707125540494 455 fps:111|1707125541494 456 fps:114|1707125542494 457 SP_daemon exec finished! 458 # 459 ``` 460 >**NOTE** 461 > 462 >- This command must be executed separately, and its collection result is not written into the **data.csv** file. 463 464 5.15 Collect the frame rate by time segment. 465 466 ``` 467 # SP_daemon -profilerfps 100 -sectrions 10 468 set num:10 success 469 fps:73|1707125301494 470 sectionsFps:0|1707125301494 471 sectionsFps:0|1707125301594 472 sectionsFps:0|1707125301694 473 sectionsFps:40|1707125301794 474 sectionsFps:120|1707125301894 475 sectionsFps:110|1707125301994 476 sectionsFps:110|1707125302094 477 sectionsFps:110|1707125302194 478 sectionsFps:120|1707125302294 479 sectionsFps:120|1707125302394 480 fps:117|1707125302494 481 ... 482 483 SP_daemon exec finished! 484 # 485 ``` 486 >**NOTE** 487 > 488 >- This command must be executed separately, and its collection result is not written into the **data.csv** file. 489 > 490 >- Currently, up to 10 segments can be collected. 491 492 5.16 Start data collection. 493 494 ``` 495 # SP_daemon -start -c 496 SP_daemon Collection begins 497 command exec finished! 498 # 499 ``` 500 501 5.17 Stop data collection. 502 503 ``` 504 # SP_daemon -stop 505 SP_daemon Collection ended 506 Output Path: data/local/tmp/smartperf/1/t_index_info_csv 507 command exec finished! 508 # 509 ``` 510 >**NOTE** 511 > 512 >- The results for the start and stop command are saved to the **data/local/tmp/smartperf/1/t_index_info.csv** file. 513 >- To view or export this file, see Step 6. 514 515 5.18 Obtain the screen resolution. 516 517 ``` 518 # SP_daemon -screen 519 activeMode: 1260x2720, refreshrate=120 520 command exec finished! 521 # 522 ``` 523 >**NOTE** 524 > 525 >- **activeMode** indicates the current screen resolution, and **refreshrate** indicates the screen refresh rate. 526 > 527 >- This command must be executed separately, and its collection result is not written into the **data.csv** file. 528 5296. Export and view the collection results. 530 531 - By default, the collection results are saved to **/data/local/tmp/data.csv**. 532 533 - To check the path to the test result file: 534 ``` 535 # cd data/local/tmp 536 # ls 537 data.csv 538 # 539 ``` 540 541 - To export the test result file: 542 ``` 543 hdc file recv data/local/tmp/data.csv D:\ 544 ``` 545 ``` 546 C:\Users\issusser>hdc file recv data/local/tmp/data.csv D:\ 547 [I][2023-11-08 16:16:41] HdcFile::TransferSummary success 548 FileTransfer finish, Size:429, File count = 1, time:6ms rate:71.50kB/s 549 550 C:\Users\issusser> 551 ``` 552 553 - Open the **data.csv** file to view data. 554 555 The table below describes the data fields in the **data.csv** file. 556 557 | Data Field | Description |Remarks| 558 | :-----| :--------------------- |:-----| 559 | cpuFrequency | CPU core frequency. |Unit: Hz| 560 | cpuUasge | CPU core usage. |%| 561 | cpuidleUsage | CPU usage in idle state. |%| 562 | cpuioWaitUsage | CPU usage of I/O wait. |%| 563 | cpuirqUsage | CPU usage of hard interrupts. |%| 564 | cpuniceUsage | CPU usage of user level processes with lower scheduling priority. |%| 565 | cpusoftIrqUsage | CPU usage of software interrupts. |%| 566 | cpusystemUsage | CPU usage in kernel mode. |%| 567 | cpuuserUsage | CPU usage in user mode. |%| 568 | ProcId | PID. | 569 | ProcAppName | Application name. || 570 | ProcCpuLoad | Process CPU load. |%| 571 | ProcCpuUsage | CPU usage of the process. |%| 572 | ProcUCpuUsage | CPU usage of the process in user mode. |%| 573 | ProcSCpuUsage | CPU usage of the process in kernel mode. |%| 574 | gpuFrequ | GPU frequency of the system. |%| 575 | gpuLoad | GPU load of the system. |%| 576 | currentNow | Current value. |Unit: mA| 577 | voltageNow | Voltage value. |Unit: μV| 578 | fps | Screen refresh rate. |Unit: FPS| 579 | fpsJitters | Frame interval. |Unit: ns| 580 | networkDown | Downstream rate. |Unit: bps| 581 | networkUp | Uplink rate. |Unit: bps| 582 | shell_front | Front cover temperature. |Unit: °C| 583 | shell_frame | Frame temperature. |Unit: °C| 584 | shell_back | Rear cover temperature. |Unit: °C| 585 | soc_thermal | System chip temperature. |Unit: °C| 586 | system_h | System temperature. |Unit: °C| 587 | Battery | Battery temperature. |Unit: °C| 588 | memAvailable | Available memory of the system. |Unit: byte| 589 | memFree | Free memory of the system. |Unit: byte| 590 | memTotal | Total memory of the system. |Unit: byte| 591 | pss | Proportional set size (PSS) of the process. |Unit: byte| 592 | timeStamp | Timestamp. |Collection time.| 593