Skip to content

Commit

Permalink
Update benchmarking macros (#3934)
Browse files Browse the repository at this point in the history
Current benchmarking macro returns a closure with the captured
benchmarked code.
This can cause issues when the benchmarked code has complex lifetime
requirements.

This PR updates the existing macro by injecting the recording parameter
and invoking the start / stop method around the benchmarked block
instead of returning a closure

One other added benefit is that you can write this kind of code now as
well:

```rust
let v;
#[block]
{ v = func.call(); }
dbg!(v); // or assert something on v
```


[Weights compare
link](https://weights.tasty.limo/compare?unit=weight&ignore_errors=true&threshold=10&method=asymptotic&repo=polkadot-sdk&old=pg/fix-weights&new=pg/bench_update&path_pattern=substrate/frame/**/src/weights.rs,polkadot/runtime/*/src/weights/**/*.rs,polkadot/bridges/modules/*/src/weights.rs,cumulus/**/weights/*.rs,cumulus/**/weights/xcm/*.rs,cumulus/**/src/weights.rs)

---------

Co-authored-by: command-bot <>
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: Alexander Theißen <alex.theissen@me.com>
  • Loading branch information
3 people authored Apr 10, 2024
1 parent ddb53c8 commit d38f6e6
Show file tree
Hide file tree
Showing 65 changed files with 11,221 additions and 10,370 deletions.
2 changes: 1 addition & 1 deletion bridges/chains/chain-bridge-hub-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,5 @@ frame_support::parameter_types! {

/// Transaction fee that is paid at the Rococo BridgeHub for delivering single outbound message confirmation.
/// (initially was calculated by test `BridgeHubRococo::can_calculate_fee_for_complex_message_confirmation_transaction` + `33%`)
pub const BridgeHubRococoBaseConfirmationFeeInRocs: u128 = 5_380_829_647;
pub const BridgeHubRococoBaseConfirmationFeeInRocs: u128 = 5_380_901_781;
}
11 changes: 11 additions & 0 deletions prdoc/pr_3934.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
title: Update benchmarking macros

doc:
- audience: Runtime Dev
description: |
Current benchmarking macro return a closure with the captured benchmarked code.
This could cause compilation issues when the benchmarked code has complex lifetime requirements.
This PR updates the existing macro by injecting the recoding parameter and invoking the start / stop method around the benchmarked block instead of returning a closure

crates: []

1,033 changes: 520 additions & 513 deletions substrate/frame/alliance/src/weights.rs

Large diffs are not rendered by default.

126 changes: 65 additions & 61 deletions substrate/frame/asset-conversion/src/weights.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d38f6e6

Please sign in to comment.