1# 编译性能分析常用工具 2 3## gn阶段性能分析 4 5### 使用gn time功能分析gn解析阶段性能 6 7编译命令:./build.sh --product-name rk3568 --ccache --gn-flags="--time" 8编译结束之后gn会输出以下内容,我们通过观察耗时较长的部分来针对性优化. 9 10~~~ 11File parse times: (time in ms, name) 12 650.18 //foundation/bundlemanager/bundle_framework/services/bundlemgr/test/unittest/bms_bundle_installer_test/BUILD.gn 13 293.70 //third_party/flutter/build/skia/BUILD.gn 14 ...... 15 16File execute times: (total time in ms, # executions, name) 17 121479.80 1 //base/startup/init/test/fuzztest/BUILD.gn 18 96465.00 1 //foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/BUILD.gn 19 ...... 20 21Script execute times: (total time in ms, # executions, name) 22 2007690.21 5694 //build/templates/common/external_deps_handler.py 23 1957474.75 4860 //build/ohos/testfwk/gen_module_list_files.py 24 ...... 25~~~ 26 27### 使用gn trace功能分析gn解析阶段性能 28 29编译命令:./build.sh --product-name rk3568 --ccache --gn-flags="--tracelog=gn.trace" 30可以将gn.trace拖动到"https://www.ui.perfetto.dev/" 来查看gn解析阶段各部分耗时以及并行度. 31 32 33 34## ninja阶段性能分析 35 36### 本地 37ninja执行过后会在对应输出目录(如out/rk3568)生成build.trace.gz文件,将其解压然后将build.trace拖动到"https://www.ui.perfetto.dev/" 来查看ninja解析阶段各部分耗时以及并行度. 38 39 40 41此外也会生成sorted_action_duration.txt,其按照降序排列每个目标的耗时. 42 43~~~ 44../kernel/src_tmp/linux-5.10/boot_linux: 431628 45arkcompiler/ets_runtime/libark_jsruntime.so: 141654 46...... 47~~~ 48 49### 门禁 50目前Openharmony ci已经默认把ninja trace转换成可直接读取的html,具体位置为: 51