README.md
1[toc]
2
3# Rom_analyzer.py
4
5## 功能介绍
6
7基于BUILD.gn、bundle.json、编译产物system_module_info.json、out/{product_name}/packages/phone目录下的编译产物,分析各子系统及部件的rom大小。
8
9结果以json与xls格式进行存储,其中,json格式是必输出的,xls格式需要-e参数控制。
10
11## 支持产品
12
13主要是rk3568系列,已测试产品包括rk3568 rk3568_mini_system
14
15## 使用说明
16
17前置条件:
18
191. 获取整个rom_ram_analyzer目录
201. 对系统进行编译
211. rom分析在linux平台,ram分析在windows平台
221. python3及以后
231. 安装requirements
24 ```txt
25 xlwt==1.3.0
26 ```
27
28命令介绍:
29
301. `-h`或`--help`命令查看帮助
31 ```shell
32 > python3 rom_analyzer.py -h
33 usage: rom_analyzer.py [-h] [-v] -p PROJECT_PATH -j MODULE_INFO_JSON -n PRODUCT_NAME -d PRODUCT_DIR [-o OUTPUT_FILE] [-e EXCEL]
34
35 analyze rom size of component.
36
37 optional arguments:
38 -h, --help show this help message and exit
39 -v, -version show program\'s version number and exit
40 -p PROJECT_PATH, --project_path PROJECT_PATH
41 root path of oh. eg: -p ~/oh
42 -j MODULE_INFO_JSON, --module_info_json MODULE_INFO_JSON
43 path of out/{product_name}/packages/phone/system_module_info.json
44 -n PRODUCT_NAME, --product_name PRODUCT_NAME
45 product name. eg: -n rk3568
46 -d PRODUCT_DIR, --product_dir PRODUCT_DIR
47 subdirectories of out/{product_name}/packages/phone to be counted.eg: -d system -d vendor
48 -o OUTPUT_FILE, --output_file OUTPUT_FILE
49 basename of output file, default: rom_analysis_result. eg: demo/rom_analysis_result
50 -e EXCEL, --excel EXCEL
51 if output result as excel, default: False. eg: -e True
52 ```
531. 使用示例
54 ```shell
55 python3 rom_analyzer.py -p ~/nomodify_oh/ -j ../system_module_info.json -n rk3568 -d system -d vendor -d updater -o demo/demo -e True
56 # oh:rootpath of oh
57 # rk3568: product_name, same as out/{product_name}
58 # demo/demo: path of output file, where the second 'demo' is the basename of output file
59 # -e True:output result in excel format additionally
60 ```
61
62## 输出格式介绍(json)
63
64
65```json
66{
67 子系统名: {
68 "size": 整个子系统输出文件的总大小,
69 "file_count": 整个子系统产生的文件数,
70 输出文件名: 本文件的大小,
71 ...
72 },
73 ...
74}
75```
76
77## 附加说明
78
791. 由于目前standard产品使用的基本都是自定义的template,能够有效收集更多信息,因此相较于lite_small的分析脚本,本脚本能够具有更高的准确率,请放心使用
80
81# ram_analyzer.py
82
83## 功能介绍
84
85基于out/{product_name}/packages/phone下所有cfg文件、out/{product_name}/packages/phone/system/profile下所有xml文件,分析各进程及对应部件的ram占用(默认取Pss)
86
87结果以json与xls格式存储,其中,json格式是必输出的,xls格式需要-e参数控制。
88
89## 使用说明
90
91前置条件:
92
931. 获取整个rom_ram_analyzer目录
942. hdc可用
952. 设备已连接
963. 系统已烧录
973. python3
984. 安装requirements
99 ```txt
100 xlwt==1.3.0
101 ```
1025. 准备好相关数据:
103 1. out/{product_name}/packages/phone下所有cfg文件,并将其放置于同一个目录中(ps:同名文件仅保存一份即可)
104 1. out/{product_name}/packages/phone/system/profile下所有xml文件
1056. 运行rom_analyzer.py产生的json结果一份(即-o参数对应的文件,默认rom_analysis_result.json)
106
107命令介绍:
108
1091. 使用`-h`或`--help`查看帮助
110 ```shell
111 > python .\ram_analyzer.py -h
112 usage: ram_analyzer.py [-h] [-v] -x XML_PATH -c CFG_PATH [-j ROM_RESULT] -n DEVICE_NUM [-o OUTPUT_FILENAME] [-e EXCEL]
113
114 analyze ram size of component
115
116 optional arguments:
117 -h, --help show this help message and exit
118 -v, -version show program\'s version number and exit
119 -x XML_PATH, --xml_path XML_PATH
120 path of xml file. eg: -x ~/oh/out/rk3568/packages/phone/system/profile
121 -c CFG_PATH, --cfg_path CFG_PATH
122 path of cfg files. eg: -c ./cfgs/
123 -j ROM_RESULT, --rom_result ROM_RESULT
124 json file produced by rom_analyzer_v1.0.py, default: ./rom_analysis_result.json.eg: -j ./demo/rom_analysis_result.json
125 -n DEVICE_NUM, --device_num DEVICE_NUM
126 device number to be collect hidumper info. eg: -n 7001005458323933328a01fce16d3800
127 -o OUTPUT_FILENAME, --output_filename OUTPUT_FILENAME
128 base name of output file, default: ram_analysis_result. eg: -o ram_analysis_result
129 -e EXCEL, --excel EXCEL
130 if output result as excel, default: False. eg: -e True
131 ```
1322. 使用示例:
133 ```shell
134 python .\ram_analyzer.py -x .\profile\ -c .\init\ -n 7001005458323933328a01fce16d3800 -j .\rom_analysis_result.json -o /demo/demo -e True
135 # demo/demo: path of output file, where the second 'demo' is the basename of output file
136 # -e True:output result in excel format additionally
137 ```
138## 输出格式说明(json)
139```json
140{
141 进程名:{
142 "size": 本进程占用内存的大小,
143 子系统名: {
144 部件名: {
145 elf文件名: elf文件大小
146 ...
147 }
148 ...
149 }
150 ...
151 },
152 ...
153}
154```