Update benchmarking macros (#3934)

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>
This commit is contained in:
PG Herveou
2024-04-10 08:44:46 +02:00
committed by GitHub
parent ddb53c87f5
commit d38f6e6728
65 changed files with 11402 additions and 10551 deletions
+26 -24
View File
@@ -17,26 +17,28 @@
//! Autogenerated weights for `pallet_sudo`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-11-07, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2024-04-09, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `runner-yprdrvc7-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! HOSTNAME: `runner-anb7yjbi-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024`
// Executed Command:
// target/production/substrate-node
// ./target/production/substrate-node
// benchmark
// pallet
// --chain=dev
// --steps=50
// --repeat=20
// --pallet=pallet_sudo
// --no-storage-info
// --no-median-slopes
// --no-min-squares
// --extrinsic=*
// --wasm-execution=compiled
// --heap-pages=4096
// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json
// --pallet=pallet_sudo
// --chain=dev
// --header=./substrate/HEADER-APACHE2
// --output=./substrate/frame/sudo/src/weights.rs
// --header=./substrate/HEADER-APACHE2
// --template=./substrate/.maintain/frame-weight-template.hbs
#![cfg_attr(rustfmt, rustfmt_skip)]
@@ -64,8 +66,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `165`
// Estimated: `1517`
// Minimum execution time: 9_600_000 picoseconds.
Weight::from_parts(10_076_000, 1517)
// Minimum execution time: 9_486_000 picoseconds.
Weight::from_parts(9_663_000, 1517)
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
@@ -75,8 +77,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `165`
// Estimated: `1517`
// Minimum execution time: 10_453_000 picoseconds.
Weight::from_parts(10_931_000, 1517)
// Minimum execution time: 10_501_000 picoseconds.
Weight::from_parts(10_729_000, 1517)
.saturating_add(T::DbWeight::get().reads(1_u64))
}
/// Storage: `Sudo::Key` (r:1 w:0)
@@ -85,8 +87,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `165`
// Estimated: `1517`
// Minimum execution time: 10_202_000 picoseconds.
Weight::from_parts(10_800_000, 1517)
// Minimum execution time: 10_742_000 picoseconds.
Weight::from_parts(11_003_000, 1517)
.saturating_add(T::DbWeight::get().reads(1_u64))
}
/// Storage: `Sudo::Key` (r:1 w:1)
@@ -95,8 +97,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `165`
// Estimated: `1517`
// Minimum execution time: 8_555_000 picoseconds.
Weight::from_parts(8_846_000, 1517)
// Minimum execution time: 8_837_000 picoseconds.
Weight::from_parts(9_127_000, 1517)
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
@@ -110,8 +112,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `165`
// Estimated: `1517`
// Minimum execution time: 9_600_000 picoseconds.
Weight::from_parts(10_076_000, 1517)
// Minimum execution time: 9_486_000 picoseconds.
Weight::from_parts(9_663_000, 1517)
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
@@ -121,8 +123,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `165`
// Estimated: `1517`
// Minimum execution time: 10_453_000 picoseconds.
Weight::from_parts(10_931_000, 1517)
// Minimum execution time: 10_501_000 picoseconds.
Weight::from_parts(10_729_000, 1517)
.saturating_add(RocksDbWeight::get().reads(1_u64))
}
/// Storage: `Sudo::Key` (r:1 w:0)
@@ -131,8 +133,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `165`
// Estimated: `1517`
// Minimum execution time: 10_202_000 picoseconds.
Weight::from_parts(10_800_000, 1517)
// Minimum execution time: 10_742_000 picoseconds.
Weight::from_parts(11_003_000, 1517)
.saturating_add(RocksDbWeight::get().reads(1_u64))
}
/// Storage: `Sudo::Key` (r:1 w:1)
@@ -141,8 +143,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `165`
// Estimated: `1517`
// Minimum execution time: 8_555_000 picoseconds.
Weight::from_parts(8_846_000, 1517)
// Minimum execution time: 8_837_000 picoseconds.
Weight::from_parts(9_127_000, 1517)
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}