1# Simpleperf 2 3Android Studio includes a graphical front end to Simpleperf, documented in 4[Inspect CPU activity with CPU Profiler](https://developer.android.com/studio/profile/cpu-profiler). 5Most users will prefer to use that instead of using Simpleperf directly. 6 7If you prefer to use the command line, Simpleperf is a versatile command-line 8CPU profiling tool included in the NDK for Mac, Linux, and Windows. 9 10This file contains documentation for simpleperf maintainers. 11 12There is also [user documentation](doc/README.md). 13 14## Building new prebuilts 15 16To snap the aosp-simpleperf-release branch to ToT AOSP main and kick off a 17build, use [this coastguard 18page](https://android-build.googleplex.com/coastguard/dashboard/5938649007521792/#/request/create) 19and choose "aosp-simpleperf-release" from the "Branch" dropdown. Then click 20"Submit build requests". You'll get emails keeping you up to date with the 21progress of the snap and the build. 22 23## Updating the prebuilts 24 25Once you have the build id (a 7-digit number) and the build is complete, run the 26update script from within the `system/extras/simpleperf` directory: 27``` 28$ ./scripts/update.py --build 1234567 29``` 30 31This will create a new change that you can `repo upload`, then approve and 32submit as normal. 33 34For testing, I usually only run python host tests as below: 35``` 36$ ./scripts/test/test.py --only-host-test 37``` 38 39To test all scripts, please use python 3.8+ and install below packages: 40``` 41$ pip install bokeh jinja2 pandas protobuf textable 42``` 43 44## Updating the prebuilts in prebuilts/simpleperf 45 46Download ndk branch. 47``` 48$ repo init -u persistent-https://android.git.corp.google.com/platform/manifest -b master-ndk 49$ repo sync 50``` 51 52In prebuilts/simpleperf, run `update.py`: 53``` 54$ ./update.py --build <bid> 55``` 56 57Then manually edit `ChangeLog`. 58This will create a new change that you can `repo upload`, then approve and submit as normal. 59 60For testing, we need to test if the scripts run on darwin/linux/windows for different android 61versions. I usually split it to four parts: 62 631. Test on android emulators running on linux x86_64 host, for android version N/O/P/Q/R/S/current. 64 65``` 66$ ./test/test.py -d <devices> -r 3 67``` 68 69The scripts support android >= N. But it's easier to test old versions on emulators. So I only test 70android N on emulators. 71 72Currently, the tests have problems in clean up. So tests on emulator may fail and take too long to 73run. And there are a few known failed cases. Hopefully they will be fixed soon. 74 751. Test on android devices connected to linux x86_64 host, for android version O/P/Q/R/S/current. 76 77``` 78$ ./test/test.py -d <devices> -r 3 79``` 80 813. Test on an android device connected to darwin x86_64 host, for one of android version O/P/Q/R/S/current. 82 83``` 84$ ./test/test.py -d <devices> -r 1 85``` 86 874. Test on an android device connected to darwin x86_64 host, for one of android version O/P/Q/R/S/current. 88 89``` 90$ ./test/test.py -d <devices> -r 1 91``` 92 93To check simpleperf contents released in ndk, we can build ndk package. 94``` 95$ <top_dir>/ndk/checkbuild.py --package --system linux --module simpleperf 96``` 97 98The ndk package is generated in `out/` directory. 99