|
7 | 7 |
|
8 | 8 | # Mock data for runtimes-matrix.json |
9 | 9 | mock_runtimes_matrix = [ |
10 | | - {"name": "dev", "package": "kitchensink-runtime", "path": "substrate/frame", "header": "substrate/HEADER-APACHE2", "template": "substrate/.maintain/frame-weight-template.hbs", "bench_features": "runtime-benchmarks,riscv"}, |
11 | | - {"name": "westend", "package": "westend-runtime", "path": "polkadot/runtime/westend", "header": "polkadot/file_header.txt", "template": "polkadot/xcm/pallet-xcm-benchmarks/template.hbs", "bench_features": "runtime-benchmarks"}, |
12 | | - {"name": "rococo", "package": "rococo-runtime", "path": "polkadot/runtime/rococo", "header": "polkadot/file_header.txt", "template": "polkadot/xcm/pallet-xcm-benchmarks/template.hbs", "bench_features": "runtime-benchmarks"}, |
13 | | - {"name": "asset-hub-westend", "package": "asset-hub-westend-runtime", "path": "cumulus/parachains/runtimes/assets/asset-hub-westend", "header": "cumulus/file_header.txt", "template": "cumulus/templates/xcm-bench-template.hbs", "bench_features": "runtime-benchmarks"}, |
| 10 | + { |
| 11 | + "name": "dev", |
| 12 | + "package": "kitchensink-runtime", |
| 13 | + "path": "substrate/frame", |
| 14 | + "header": "substrate/HEADER-APACHE2", |
| 15 | + "template": "substrate/.maintain/frame-weight-template.hbs", |
| 16 | + "bench_features": "runtime-benchmarks,riscv", |
| 17 | + "bench_flags": "--flag1 --flag2" |
| 18 | + }, |
| 19 | + { |
| 20 | + "name": "westend", |
| 21 | + "package": "westend-runtime", |
| 22 | + "path": "polkadot/runtime/westend", |
| 23 | + "header": "polkadot/file_header.txt", |
| 24 | + "template": "polkadot/xcm/pallet-xcm-benchmarks/template.hbs", |
| 25 | + "bench_features": "runtime-benchmarks", |
| 26 | + "bench_flags": "--flag3 --flag4" |
| 27 | + }, |
| 28 | + { |
| 29 | + "name": "rococo", |
| 30 | + "package": "rococo-runtime", |
| 31 | + "path": "polkadot/runtime/rococo", |
| 32 | + "header": "polkadot/file_header.txt", |
| 33 | + "template": "polkadot/xcm/pallet-xcm-benchmarks/template.hbs", |
| 34 | + "bench_features": "runtime-benchmarks", |
| 35 | + "bench_flags": "" |
| 36 | + }, |
| 37 | + { |
| 38 | + "name": "asset-hub-westend", |
| 39 | + "package": "asset-hub-westend-runtime", |
| 40 | + "path": "cumulus/parachains/runtimes/assets/asset-hub-westend", |
| 41 | + "header": "cumulus/file_header.txt", |
| 42 | + "template": "cumulus/templates/xcm-bench-template.hbs", |
| 43 | + "bench_features": "runtime-benchmarks", |
| 44 | + "bench_flags": "--flag7 --flag8" |
| 45 | + } |
14 | 46 | ] |
15 | 47 |
|
16 | | -def get_mock_bench_output(runtime, pallets, output_path, header, template = None): |
| 48 | +def get_mock_bench_output(runtime, pallets, output_path, header, bench_flags, template = None): |
17 | 49 | return f"frame-omni-bencher v1 benchmark pallet --extrinsic=* " \ |
18 | 50 | f"--runtime=target/release/wbuild/{runtime}-runtime/{runtime.replace('-', '_')}_runtime.wasm " \ |
19 | 51 | f"--pallet={pallets} --header={header} " \ |
20 | 52 | f"--output={output_path} " \ |
21 | 53 | f"--wasm-execution=compiled " \ |
22 | 54 | f"--steps=50 --repeat=20 --heap-pages=4096 " \ |
23 | 55 | f"{f'--template={template} ' if template else ''}" \ |
24 | | - f"--no-storage-info --no-min-squares --no-median-slopes" |
| 56 | + f"--no-storage-info --no-min-squares --no-median-slopes " \ |
| 57 | + f"{bench_flags}" |
25 | 58 |
|
26 | 59 | class TestCmd(unittest.TestCase): |
27 | 60 |
|
@@ -89,10 +122,29 @@ def test_bench_command_normal_execution_all_runtimes(self): |
89 | 122 | call("forklift cargo build -p rococo-runtime --profile release --features=runtime-benchmarks"), |
90 | 123 | call("forklift cargo build -p asset-hub-westend-runtime --profile release --features=runtime-benchmarks"), |
91 | 124 |
|
92 | | - call(get_mock_bench_output('kitchensink', 'pallet_balances', './substrate/frame/balances/src/weights.rs', os.path.abspath('substrate/HEADER-APACHE2'), "substrate/.maintain/frame-weight-template.hbs")), |
93 | | - call(get_mock_bench_output('westend', 'pallet_balances', './polkadot/runtime/westend/src/weights', os.path.abspath('polkadot/file_header.txt'))), |
| 125 | + call(get_mock_bench_output( |
| 126 | + runtime='kitchensink', |
| 127 | + pallets='pallet_balances', |
| 128 | + output_path='./substrate/frame/balances/src/weights.rs', |
| 129 | + header=os.path.abspath('substrate/HEADER-APACHE2'), |
| 130 | + bench_flags='--flag1 --flag2', |
| 131 | + template="substrate/.maintain/frame-weight-template.hbs" |
| 132 | + )), |
| 133 | + call(get_mock_bench_output( |
| 134 | + runtime='westend', |
| 135 | + pallets='pallet_balances', |
| 136 | + output_path='./polkadot/runtime/westend/src/weights', |
| 137 | + header=os.path.abspath('polkadot/file_header.txt'), |
| 138 | + bench_flags='--flag3 --flag4' |
| 139 | + )), |
94 | 140 | # skips rococo benchmark |
95 | | - call(get_mock_bench_output('asset-hub-westend', 'pallet_balances', './cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights', os.path.abspath('cumulus/file_header.txt'))), |
| 141 | + call(get_mock_bench_output( |
| 142 | + runtime='asset-hub-westend', |
| 143 | + pallets='pallet_balances', |
| 144 | + output_path='./cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights', |
| 145 | + header=os.path.abspath('cumulus/file_header.txt'), |
| 146 | + bench_flags='--flag7 --flag8' |
| 147 | + )), |
96 | 148 | ] |
97 | 149 | self.mock_system.assert_has_calls(expected_calls, any_order=True) |
98 | 150 |
|
@@ -121,8 +173,20 @@ def test_bench_command_normal_execution(self): |
121 | 173 | call("forklift cargo build -p westend-runtime --profile release --features=runtime-benchmarks"), |
122 | 174 |
|
123 | 175 | # Westend runtime calls |
124 | | - call(get_mock_bench_output('westend', 'pallet_balances', './polkadot/runtime/westend/src/weights', header_path)), |
125 | | - call(get_mock_bench_output('westend', 'pallet_staking', './polkadot/runtime/westend/src/weights', header_path)), |
| 176 | + call(get_mock_bench_output( |
| 177 | + runtime='westend', |
| 178 | + pallets='pallet_balances', |
| 179 | + output_path='./polkadot/runtime/westend/src/weights', |
| 180 | + header=header_path, |
| 181 | + bench_flags='--flag3 --flag4' |
| 182 | + )), |
| 183 | + call(get_mock_bench_output( |
| 184 | + runtime='westend', |
| 185 | + pallets='pallet_staking', |
| 186 | + output_path='./polkadot/runtime/westend/src/weights', |
| 187 | + header=header_path, |
| 188 | + bench_flags='--flag3 --flag4' |
| 189 | + )), |
126 | 190 | ] |
127 | 191 | self.mock_system.assert_has_calls(expected_calls, any_order=True) |
128 | 192 |
|
@@ -153,11 +217,12 @@ def test_bench_command_normal_execution_xcm(self): |
153 | 217 |
|
154 | 218 | # Westend runtime calls |
155 | 219 | call(get_mock_bench_output( |
156 | | - 'westend', |
157 | | - 'pallet_xcm_benchmarks::generic', |
158 | | - './polkadot/runtime/westend/src/weights/xcm', |
159 | | - header_path, |
160 | | - "polkadot/xcm/pallet-xcm-benchmarks/template.hbs" |
| 220 | + runtime='westend', |
| 221 | + pallets='pallet_xcm_benchmarks::generic', |
| 222 | + output_path='./polkadot/runtime/westend/src/weights/xcm', |
| 223 | + header=header_path, |
| 224 | + bench_flags='--flag3 --flag4', |
| 225 | + template="polkadot/xcm/pallet-xcm-benchmarks/template.hbs" |
161 | 226 | )), |
162 | 227 | ] |
163 | 228 | self.mock_system.assert_has_calls(expected_calls, any_order=True) |
@@ -188,11 +253,35 @@ def test_bench_command_two_runtimes_two_pallets(self): |
188 | 253 | call("forklift cargo build -p westend-runtime --profile release --features=runtime-benchmarks"), |
189 | 254 | call("forklift cargo build -p rococo-runtime --profile release --features=runtime-benchmarks"), |
190 | 255 | # Westend runtime calls |
191 | | - call(get_mock_bench_output('westend', 'pallet_staking', './polkadot/runtime/westend/src/weights', header_path)), |
192 | | - call(get_mock_bench_output('westend', 'pallet_balances', './polkadot/runtime/westend/src/weights', header_path)), |
| 256 | + call(get_mock_bench_output( |
| 257 | + runtime='westend', |
| 258 | + pallets='pallet_staking', |
| 259 | + output_path='./polkadot/runtime/westend/src/weights', |
| 260 | + header=header_path, |
| 261 | + bench_flags='--flag3 --flag4' |
| 262 | + )), |
| 263 | + call(get_mock_bench_output( |
| 264 | + runtime='westend', |
| 265 | + pallets='pallet_balances', |
| 266 | + output_path='./polkadot/runtime/westend/src/weights', |
| 267 | + header=header_path, |
| 268 | + bench_flags='--flag3 --flag4' |
| 269 | + )), |
193 | 270 | # Rococo runtime calls |
194 | | - call(get_mock_bench_output('rococo', 'pallet_staking', './polkadot/runtime/rococo/src/weights', header_path)), |
195 | | - call(get_mock_bench_output('rococo', 'pallet_balances', './polkadot/runtime/rococo/src/weights', header_path)), |
| 271 | + call(get_mock_bench_output( |
| 272 | + runtime='rococo', |
| 273 | + pallets='pallet_staking', |
| 274 | + output_path='./polkadot/runtime/rococo/src/weights', |
| 275 | + header=header_path, |
| 276 | + bench_flags='' |
| 277 | + )), |
| 278 | + call(get_mock_bench_output( |
| 279 | + runtime='rococo', |
| 280 | + pallets='pallet_balances', |
| 281 | + output_path='./polkadot/runtime/rococo/src/weights', |
| 282 | + header=header_path, |
| 283 | + bench_flags='' |
| 284 | + )), |
196 | 285 | ] |
197 | 286 | self.mock_system.assert_has_calls(expected_calls, any_order=True) |
198 | 287 |
|
@@ -223,11 +312,12 @@ def test_bench_command_one_dev_runtime(self): |
223 | 312 | call("forklift cargo build -p kitchensink-runtime --profile release --features=runtime-benchmarks,riscv"), |
224 | 313 | # Westend runtime calls |
225 | 314 | call(get_mock_bench_output( |
226 | | - 'kitchensink', |
227 | | - 'pallet_balances', |
228 | | - manifest_dir + "/src/weights.rs", |
229 | | - header_path, |
230 | | - "substrate/.maintain/frame-weight-template.hbs" |
| 315 | + runtime='kitchensink', |
| 316 | + pallets='pallet_balances', |
| 317 | + output_path=manifest_dir + "/src/weights.rs", |
| 318 | + header=header_path, |
| 319 | + bench_flags='--flag1 --flag2', |
| 320 | + template="substrate/.maintain/frame-weight-template.hbs" |
231 | 321 | )), |
232 | 322 | ] |
233 | 323 | self.mock_system.assert_has_calls(expected_calls, any_order=True) |
@@ -257,10 +347,11 @@ def test_bench_command_one_cumulus_runtime(self): |
257 | 347 | call("forklift cargo build -p asset-hub-westend-runtime --profile release --features=runtime-benchmarks"), |
258 | 348 | # Asset-hub-westend runtime calls |
259 | 349 | call(get_mock_bench_output( |
260 | | - 'asset-hub-westend', |
261 | | - 'pallet_assets', |
262 | | - './cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights', |
263 | | - header_path |
| 350 | + runtime='asset-hub-westend', |
| 351 | + pallets='pallet_assets', |
| 352 | + output_path='./cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights', |
| 353 | + header=header_path, |
| 354 | + bench_flags='--flag7 --flag8' |
264 | 355 | )), |
265 | 356 | ] |
266 | 357 |
|
@@ -291,17 +382,19 @@ def test_bench_command_one_cumulus_runtime_xcm(self): |
291 | 382 | call("forklift cargo build -p asset-hub-westend-runtime --profile release --features=runtime-benchmarks"), |
292 | 383 | # Asset-hub-westend runtime calls |
293 | 384 | call(get_mock_bench_output( |
294 | | - 'asset-hub-westend', |
295 | | - 'pallet_xcm_benchmarks::generic', |
296 | | - './cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm', |
297 | | - header_path, |
298 | | - "cumulus/templates/xcm-bench-template.hbs" |
| 385 | + runtime='asset-hub-westend', |
| 386 | + pallets='pallet_xcm_benchmarks::generic', |
| 387 | + output_path='./cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm', |
| 388 | + header=header_path, |
| 389 | + bench_flags='--flag7 --flag8', |
| 390 | + template="cumulus/templates/xcm-bench-template.hbs" |
299 | 391 | )), |
300 | 392 | call(get_mock_bench_output( |
301 | | - 'asset-hub-westend', |
302 | | - 'pallet_assets', |
303 | | - './cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights', |
304 | | - header_path |
| 393 | + runtime='asset-hub-westend', |
| 394 | + pallets='pallet_assets', |
| 395 | + output_path='./cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights', |
| 396 | + header=header_path, |
| 397 | + bench_flags='--flag7 --flag8' |
305 | 398 | )), |
306 | 399 | ] |
307 | 400 |
|
|
0 commit comments