1# 自动构建性能测试脚本 2 3## 脚本目的 4自动构建指定的工程,构建多次后取平均值输出构建的时间以及abc的大小 5 6## 脚本使用 7### 运行环境 8测试自动化脚本运行环境为windows,pandas, json5, python3.9 9### 脚本运行 10输入命令 python performance_entry.py 11 12### 详细设置内容 13需要在performance_config.py中修改以下内容 14project_path,node_js_path,jbr_path 这三个必须根据环境配置,其他的可以用默认的 15如果不使用默认的,则可以像HelloWorld中那样配置 16修改run_list 以指定需要运行的工程 17``` 18 send_mail = True 19 run_list = ["FTB", "FDY", "FWX"] 20 21 def __init__(self): 22 # Default config settings for all projects, if it's not what you need, config them in application_configs 23 self.cmd_prefix = r"hvigorw.bat" 24``` 25 26``` 27 def __init__(self): 28 ... 29 30 # Do not build the project,use the test data if you need to debug the scripts 31 self.developing_test_mode = False 32 # set your node_js path 33 self.node_js_path = r"C:/xxx" 34 # Must set according environment 35 self.jbr_path = r'xxx\DevEco Studio\jbr' 36``` 37 38``` 39application_configs = dict( 40 [ 41 ( 42 "FTB", dict 43 ( 44 project_path = r"D:\FTB", 45 ) 46 ), 47 ( 48 "FDY", dict 49 ( 50 project_path = r"D:\FDY", 51 ) 52 ), 53 ( 54 "FWX", dict 55 ( 56 project_path = r"D:\FWX", 57 ) 58 ), 59 ( 60 "HelloWorld", dict 61 ( 62 # The following params must be set according you environment 63 project_path = r"xxx", 64 65 # The following params is not neccessary to be modified 66 debug_package_path = r'entry\build\default\outputs\default\entry-default-unsigned.hap', 67 release_package_path = r'entry\build\default\outputs\default\app\entry-default.hap', 68 incremental_code_path = r'entry\src\main\ets\pages\Index.ets', 69 incremental_code_end_pos = 'build() {', 70 incremental_code_str = "a: number = 5 + 6\n", 71 incremental_code_start_pos = "a: number = 5 + 6\n", 72 ) 73 ) 74 ] 75) 76``` 77 78更多细节: 79**jbr路径** 80jbr_path = r'xxx\DevEco Studio\jbr' 81 82**目标工程的路径** 83project_path = r"D"\xxx" 84 85**图片所示app的名字** 86name = r'FTB' 87 88**AS = 1 DevEco = 2** 89IDE = 2 90 91**构建使用的cmd指令** 92cmd_prefix = r"hvigorw.bat" 93**开头有空格** 94cmd_debug_suffix = ' --mode module -p product=default assembleHap' 95cmd_release_suffix = ' --mode project -p product=default assembleApp' 96 97**生成的安装包路径** 98debug_package_path = r'entry\build\default\outputs\default\entry-default-unsigned.hap' 99release_package_path = r'entry\build\default\outputs\default\app\entry-default.hap' 100 101**增量编译时修改以下文件** 102incremental_code_path = 'entry\src\main\ets\pages\Index.ets' 103 104**增量编译时添加以下代码** 105incremental_code_str = "let index = 5 + 6\n" 106 107**代码将会添加到下面这行代码的前面** 108incremental_code_end_pos = 'this.num = num' 109 110**通过找到下面的代码,来还原代码文件** 111incremental_code_start_pos = "let index = 5 + 6\n" 112 113**file which controls aotCompileMode in type or not** 114json5_path = 'xxx/build-profile.json5' 115 116**存放log文件的目录** 117log_direct = r"buildTestData" 118 119**输出的文件名,默认是[IDE_filename]_[debug_or_release]_[build_type_of_log]_[logFileName.xslx],比如:DevEco_Debug_Incremental_sizeAve.xlsx** 120output_split = "_" 121IDE_filename = ["AS", "DevEco"] 122debug_or_release = ["Debug", "Release"] 123build_type_of_log = ["Incremental", "fullBuild"] 124**size 表示log里记录了hap中abc的大小,time记录了构建耗时,All表示记录全部数据,Avg表示平均值** 125log_filename = ["sizeAll.xlsx", "sizeAve.xlsx","timeAll.xlsx", "timeAve.xlsx"] 126 127**配置的APP会显示更精细的构建耗时,不配置则不显示** 128show_time_detail_filter = ["createProgram", "arkTSLinter", "tsProgramEmit", 129 "generate content and source map information", "write obfuscated source code", 130 "write source map (async)", "generate merged abc by es2abc (async)", "total build cost" 131 ] 132 133**跳过build阶段,使用测试数据,修改脚本时调试使用. ''为不使用测试模式,test_report.json测试构建成功的模式,test_error_report.json测试构建失败报错的场景** 134developing_test_data_path = ''