tree: ceef8fe638bee8ffbd806471308fff78e7afb14f
  1. app_api/
  2. demo/
  3. doc/
  4. fuzzer_scripts/
  5. include/
  6. nonlinux_support/
  7. runtest/
  8. rust/
  9. scripts/
  10. simpleperf_app_runner/
  11. testdata/
  12. .gitignore
  13. AddrFilter.cpp
  14. AddrFilter.h
  15. AddrFilter_test.cpp
  16. Android.bp
  17. branch_list.proto
  18. BranchListFile.cpp
  19. BranchListFile.h
  20. BranchListFile_test.cpp
  21. build_id.h
  22. callchain.h
  23. CallChainJoiner.cpp
  24. CallChainJoiner.h
  25. CallChainJoiner_test.cpp
  26. cmd_api.cpp
  27. cmd_api_impl.h
  28. cmd_api_test.cpp
  29. cmd_boot_record.cpp
  30. cmd_boot_record_test.cpp
  31. cmd_debug_unwind.cpp
  32. cmd_debug_unwind_test.cpp
  33. cmd_dumprecord.cpp
  34. cmd_dumprecord_test.cpp
  35. cmd_help.cpp
  36. cmd_inject.cpp
  37. cmd_inject_test.cpp
  38. cmd_kmem.cpp
  39. cmd_kmem_test.cpp
  40. cmd_list.cpp
  41. cmd_list_test.cpp
  42. cmd_merge.cpp
  43. cmd_merge_test.cpp
  44. cmd_monitor.cpp
  45. cmd_monitor_test.cpp
  46. cmd_record.cpp
  47. cmd_record_impl.h
  48. cmd_record_test.cpp
  49. cmd_report.cpp
  50. cmd_report_sample.cpp
  51. cmd_report_sample.proto
  52. cmd_report_sample_test.cpp
  53. cmd_report_test.cpp
  54. cmd_stat.cpp
  55. cmd_stat_impl.h
  56. cmd_stat_test.cpp
  57. cmd_trace_sched.cpp
  58. cmd_trace_sched_test.cpp
  59. command.cpp
  60. command.h
  61. command_test.cpp
  62. cpu_hotplug_test.cpp
  63. dso.cpp
  64. dso.h
  65. dso_test.cpp
  66. environment.cpp
  67. environment.h
  68. environment_test.cpp
  69. ETMConstants.h
  70. ETMDecoder.cpp
  71. ETMDecoder.h
  72. ETMRecorder.cpp
  73. ETMRecorder.h
  74. ETMRecorder_test.cpp
  75. event_attr.cpp
  76. event_attr.h
  77. event_fd.cpp
  78. event_fd.h
  79. event_selection_set.cpp
  80. event_selection_set.h
  81. event_selection_set_test.cpp
  82. event_table.json
  83. event_table_generator.py
  84. event_table_json_generator.py
  85. event_type.cpp
  86. event_type.h
  87. get_test_data.h
  88. gtest_main.cpp
  89. IOEventLoop.cpp
  90. IOEventLoop.h
  91. IOEventLoop_test.cpp
  92. JITDebugReader.cpp
  93. JITDebugReader.h
  94. JITDebugReader_impl.h
  95. JITDebugReader_test.cpp
  96. kallsyms.cpp
  97. kallsyms.h
  98. kallsyms_test.cpp
  99. libsimpleperf_report_fuzzer.cpp
  100. main.cpp
  101. MapRecordReader.cpp
  102. MapRecordReader.h
  103. MapRecordReader_test.cpp
  104. NOTICE
  105. OfflineUnwinder.cpp
  106. OfflineUnwinder.h
  107. OfflineUnwinder_impl.h
  108. OfflineUnwinder_test.cpp
  109. OWNERS
  110. perf_event.h
  111. perf_regs.cpp
  112. perf_regs.h
  113. perf_regs_test.cpp
  114. ProbeEvents.cpp
  115. ProbeEvents.h
  116. ProbeEvents_test.cpp
  117. profcollect.cpp
  118. read_apk.cpp
  119. read_apk.h
  120. read_apk_test.cpp
  121. read_dex_file.cpp
  122. read_dex_file.h
  123. read_dex_file_test.cpp
  124. read_elf.cpp
  125. read_elf.h
  126. read_elf_test.cpp
  127. read_symbol_map.cpp
  128. read_symbol_map.h
  129. read_symbol_map_test.cpp
  130. README.md
  131. record.cpp
  132. record.h
  133. record_equal_test.h
  134. record_file.h
  135. record_file.proto
  136. record_file_format.h
  137. record_file_reader.cpp
  138. record_file_test.cpp
  139. record_file_writer.cpp
  140. record_lib_interface.cpp
  141. record_lib_test.cpp
  142. record_test.cpp
  143. RecordFilter.cpp
  144. RecordFilter.h
  145. RecordFilter_test.cpp
  146. RecordReadThread.cpp
  147. RecordReadThread.h
  148. RecordReadThread_test.cpp
  149. RegEx.cpp
  150. RegEx.h
  151. RegEx_test.cpp
  152. report_lib_interface.cpp
  153. report_utils.cpp
  154. report_utils.h
  155. report_utils_interface.cpp
  156. report_utils_test.cpp
  157. sample_tree.h
  158. sample_tree_test.cpp
  159. SampleComparator.h
  160. SampleDisplayer.h
  161. simpleperf.rc
  162. simpleperf_dict.dict
  163. simpleperf_writer_fuzzer.cpp
  164. SPEDecoder.cpp
  165. SPEDecoder.h
  166. SPERecorder.cpp
  167. SPERecorder.h
  168. TEST_MAPPING
  169. test_util.cpp
  170. test_util.h
  171. thread_tree.cpp
  172. thread_tree.h
  173. thread_tree_test.cpp
  174. tracing.cpp
  175. tracing.h
  176. tracing_test.cpp
  177. utils.cpp
  178. utils.h
  179. utils_test.cpp
  180. workload.cpp
  181. workload.h
  182. workload_test.cpp
  183. ZstdUtil.cpp
  184. ZstdUtil.h
  185. ZstdUtil_test.cpp
simpleperf/README.md

Simpleperf

Android Studio includes a graphical front end to Simpleperf, documented in Inspect CPU activity with CPU Profiler. Most users will prefer to use that instead of using Simpleperf directly.

If you prefer to use the command line, Simpleperf is a versatile command-line CPU profiling tool included in the NDK for Mac, Linux, and Windows.

This file contains documentation for simpleperf maintainers.

There is also user documentation.

Updating the prebuilts in system/extras/simpleperf

Find the latest green build of simpleperf targets in ab/git_main-without-vendor. Once you have the build id (a 7-digit number) and the build is complete, run the update script from within the system/extras/simpleperf directory:

$ ./scripts/update.py --build <build id>

This will create a new change that you can repo upload, then approve and submit as normal.

For testing, we usually only run python host tests as below:

$ ./scripts/test/test.py --only-host-test

To test all scripts, please use python 3.8+ and install below packages:

$ pip install bokeh jinja2 pandas protobuf textable

Updating the prebuilts in prebuilts/simpleperf (for NDK)

Find the latest green build of simpleperf targets in ab/git_main-without-vendor.

$ git clone https://googleplex-android.googlesource.com/platform/prebuilts/simpleperf
$ cd simpleperf
$ ./update --build <build id>

Then manually edit ChangeLog or use Gemini to generate it. This will create a new change that we can upload for review.

$ git push origin HEAD:refs/for/main

For testing, we need to test if the scripts run on Darwin/Linux/Windows for different Android versions in 4 steps:

  1. Test on Android emulators running on a Linux x86_64 host, for Android version N to current.
$ ./test/test.py -d <devices> -r 3

The scripts support Android >= N. But it's easier to test old versions on emulators. So we only test Android N on emulators.

Currently, the tests have problems in clean up. So tests on emulators may fail and take too long to run. And there are a few known failed cases. Hopefully they will be fixed soon.

  1. Test on Android devices connected to a Linux x86_64 host, for Android version O to current.
$ ./test/test.py -d <devices> -r 3
  1. Test on an Android device connected to a Darwin x86_64 host, for one of Android version O to current.
$ ./test/test.py -d <devices> -r 1
  1. Test on an Android device connected to a Windows x86_64 host, for one of Android version O to current.
$ ./test/test.py -d <devices> -r 1

To check simpleperf contents released in NDK, we can build the NDK package in an NDK branch.

$ repo init -u persistent-https://android.git.corp.google.com/platform/manifest -b master-ndk
$ repo sync
$ ndk/checkbuild.py --package --system linux --module simpleperf

The NDK package is generated in the out/ directory.

After merging the prebuilt update, the CL can be cherry-picked to NDK release branches.