Expose Benchmarking Component Ranges (#11545)

* Add component ranges to benchmarking

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Adding component ranges to templates

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Fix tests

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* cargo run --quiet --profile=production  --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark pallet --chain=dev --steps=50 --repeat=20 --pallet=frame_system --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/system/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* tweak script to reduce diff

* cargo run --quiet --profile=production  --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark pallet --chain=dev --steps=50 --repeat=20 --pallet=pallet_identity --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/identity/src/weights.rs --template=./.maintain/frame-weight-template.hbs

Co-authored-by: Parity Bot <admin@parity.io>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
Oliver Tale-Yazdi
2022-06-03 22:43:54 +02:00
committed by GitHub
parent a2afadb123
commit eb4be02155
7 changed files with 220 additions and 115 deletions
@@ -56,6 +56,9 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
{{#each benchmark.comments as |comment|}} {{#each benchmark.comments as |comment|}}
// {{comment}} // {{comment}}
{{/each}} {{/each}}
{{#each benchmark.component_ranges as |range|}}
/// The range of component `{{range.name}}` is `[{{range.min}}, {{range.max}}]`.
{{/each}}
fn {{benchmark.name~}} fn {{benchmark.name~}}
( (
{{~#each benchmark.components as |c| ~}} {{~#each benchmark.components as |c| ~}}
@@ -88,6 +91,9 @@ impl WeightInfo for () {
{{#each benchmark.comments as |comment|}} {{#each benchmark.comments as |comment|}}
// {{comment}} // {{comment}}
{{/each}} {{/each}}
{{#each benchmark.component_ranges as |range|}}
/// The range of component `{{range.name}}` is `[{{range.min}}, {{range.max}}]`.
{{/each}}
fn {{benchmark.name~}} fn {{benchmark.name~}}
( (
{{~#each benchmark.components as |c| ~}} {{~#each benchmark.components as |c| ~}}
+158 -105
View File
@@ -18,11 +18,11 @@
//! Autogenerated weights for pallet_identity //! Autogenerated weights for pallet_identity
//! //!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2022-05-23, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! DATE: 2022-06-03, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024
// Executed Command: // Executed Command:
// ./target/production/substrate // target/production/substrate
// benchmark // benchmark
// pallet // pallet
// --chain=dev // --chain=dev
@@ -32,8 +32,9 @@
// --extrinsic=* // --extrinsic=*
// --execution=wasm // --execution=wasm
// --wasm-execution=compiled // --wasm-execution=compiled
// --template=./.maintain/frame-weight-template.hbs // --heap-pages=4096
// --output=./frame/identity/src/weights.rs // --output=./frame/identity/src/weights.rs
// --template=./.maintain/frame-weight-template.hbs
#![cfg_attr(rustfmt, rustfmt_skip)] #![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)] #![allow(unused_parens)]
@@ -66,30 +67,34 @@ pub trait WeightInfo {
pub struct SubstrateWeight<T>(PhantomData<T>); pub struct SubstrateWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> { impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: Identity Registrars (r:1 w:1) // Storage: Identity Registrars (r:1 w:1)
/// The range of component `r` is `[1, 19]`.
fn add_registrar(r: u32, ) -> Weight { fn add_registrar(r: u32, ) -> Weight {
(16_343_000 as Weight) (16_649_000 as Weight)
// Standard Error: 5_000 // Standard Error: 5_000
.saturating_add((229_000 as Weight).saturating_mul(r as Weight)) .saturating_add((241_000 as Weight).saturating_mul(r as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
// Storage: Identity IdentityOf (r:1 w:1) // Storage: Identity IdentityOf (r:1 w:1)
/// The range of component `r` is `[1, 20]`.
/// The range of component `x` is `[1, 100]`.
fn set_identity(r: u32, x: u32, ) -> Weight { fn set_identity(r: u32, x: u32, ) -> Weight {
(32_920_000 as Weight) (31_322_000 as Weight)
// Standard Error: 8_000 // Standard Error: 10_000
.saturating_add((203_000 as Weight).saturating_mul(r as Weight)) .saturating_add((252_000 as Weight).saturating_mul(r as Weight))
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((300_000 as Weight).saturating_mul(x as Weight)) .saturating_add((312_000 as Weight).saturating_mul(x as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
// Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity IdentityOf (r:1 w:0)
// Storage: Identity SubsOf (r:1 w:1) // Storage: Identity SubsOf (r:1 w:1)
// Storage: Identity SuperOf (r:1 w:1) // Storage: Identity SuperOf (r:1 w:1)
/// The range of component `s` is `[1, 100]`.
fn set_subs_new(s: u32, ) -> Weight { fn set_subs_new(s: u32, ) -> Weight {
(31_009_000 as Weight) (30_012_000 as Weight)
// Standard Error: 1_000 // Standard Error: 2_000
.saturating_add((3_053_000 as Weight).saturating_mul(s as Weight)) .saturating_add((3_005_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight)))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
@@ -98,10 +103,11 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity IdentityOf (r:1 w:0)
// Storage: Identity SubsOf (r:1 w:1) // Storage: Identity SubsOf (r:1 w:1)
// Storage: Identity SuperOf (r:0 w:1) // Storage: Identity SuperOf (r:0 w:1)
/// The range of component `p` is `[1, 100]`.
fn set_subs_old(p: u32, ) -> Weight { fn set_subs_old(p: u32, ) -> Weight {
(29_712_000 as Weight) (29_623_000 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((1_087_000 as Weight).saturating_mul(p as Weight)) .saturating_add((1_100_000 as Weight).saturating_mul(p as Weight))
.saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
.saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight))) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight)))
@@ -109,71 +115,83 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: Identity SubsOf (r:1 w:1) // Storage: Identity SubsOf (r:1 w:1)
// Storage: Identity IdentityOf (r:1 w:1) // Storage: Identity IdentityOf (r:1 w:1)
// Storage: Identity SuperOf (r:0 w:100) // Storage: Identity SuperOf (r:0 w:100)
/// The range of component `r` is `[1, 20]`.
/// The range of component `s` is `[1, 100]`.
/// The range of component `x` is `[1, 100]`.
fn clear_identity(r: u32, s: u32, x: u32, ) -> Weight { fn clear_identity(r: u32, s: u32, x: u32, ) -> Weight {
(33_943_000 as Weight) (34_370_000 as Weight)
// Standard Error: 7_000 // Standard Error: 10_000
.saturating_add((193_000 as Weight).saturating_mul(r as Weight)) .saturating_add((186_000 as Weight).saturating_mul(r as Weight))
// Standard Error: 0 // Standard Error: 1_000
.saturating_add((1_101_000 as Weight).saturating_mul(s as Weight)) .saturating_add((1_114_000 as Weight).saturating_mul(s as Weight))
// Standard Error: 0 // Standard Error: 1_000
.saturating_add((194_000 as Weight).saturating_mul(x as Weight)) .saturating_add((189_000 as Weight).saturating_mul(x as Weight))
.saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight))
.saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight)))
} }
// Storage: Identity Registrars (r:1 w:0) // Storage: Identity Registrars (r:1 w:0)
// Storage: Identity IdentityOf (r:1 w:1) // Storage: Identity IdentityOf (r:1 w:1)
/// The range of component `r` is `[1, 20]`.
/// The range of component `x` is `[1, 100]`.
fn request_judgement(r: u32, x: u32, ) -> Weight { fn request_judgement(r: u32, x: u32, ) -> Weight {
(34_861_000 as Weight) (34_759_000 as Weight)
// Standard Error: 3_000 // Standard Error: 4_000
.saturating_add((249_000 as Weight).saturating_mul(r as Weight)) .saturating_add((251_000 as Weight).saturating_mul(r as Weight))
// Standard Error: 0 // Standard Error: 0
.saturating_add((344_000 as Weight).saturating_mul(x as Weight)) .saturating_add((340_000 as Weight).saturating_mul(x as Weight))
.saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
// Storage: Identity IdentityOf (r:1 w:1) // Storage: Identity IdentityOf (r:1 w:1)
/// The range of component `r` is `[1, 20]`.
/// The range of component `x` is `[1, 100]`.
fn cancel_request(r: u32, x: u32, ) -> Weight { fn cancel_request(r: u32, x: u32, ) -> Weight {
(32_906_000 as Weight) (32_254_000 as Weight)
// Standard Error: 3_000 // Standard Error: 7_000
.saturating_add((147_000 as Weight).saturating_mul(r as Weight)) .saturating_add((159_000 as Weight).saturating_mul(r as Weight))
// Standard Error: 0 // Standard Error: 0
.saturating_add((341_000 as Weight).saturating_mul(x as Weight)) .saturating_add((347_000 as Weight).saturating_mul(x as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
// Storage: Identity Registrars (r:1 w:1) // Storage: Identity Registrars (r:1 w:1)
/// The range of component `r` is `[1, 19]`.
fn set_fee(r: u32, ) -> Weight { fn set_fee(r: u32, ) -> Weight {
(7_591_000 as Weight) (7_858_000 as Weight)
// Standard Error: 3_000 // Standard Error: 3_000
.saturating_add((201_000 as Weight).saturating_mul(r as Weight)) .saturating_add((190_000 as Weight).saturating_mul(r as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
// Storage: Identity Registrars (r:1 w:1) // Storage: Identity Registrars (r:1 w:1)
/// The range of component `r` is `[1, 19]`.
fn set_account_id(r: u32, ) -> Weight { fn set_account_id(r: u32, ) -> Weight {
(7_919_000 as Weight) (8_011_000 as Weight)
// Standard Error: 3_000 // Standard Error: 3_000
.saturating_add((183_000 as Weight).saturating_mul(r as Weight)) .saturating_add((187_000 as Weight).saturating_mul(r as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
// Storage: Identity Registrars (r:1 w:1) // Storage: Identity Registrars (r:1 w:1)
/// The range of component `r` is `[1, 19]`.
fn set_fields(r: u32, ) -> Weight { fn set_fields(r: u32, ) -> Weight {
(7_887_000 as Weight) (7_970_000 as Weight)
// Standard Error: 4_000 // Standard Error: 3_000
.saturating_add((182_000 as Weight).saturating_mul(r as Weight)) .saturating_add((175_000 as Weight).saturating_mul(r as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
// Storage: Identity Registrars (r:1 w:0) // Storage: Identity Registrars (r:1 w:0)
// Storage: Identity IdentityOf (r:1 w:1) // Storage: Identity IdentityOf (r:1 w:1)
/// The range of component `r` is `[1, 19]`.
/// The range of component `x` is `[1, 100]`.
fn provide_judgement(r: u32, x: u32, ) -> Weight { fn provide_judgement(r: u32, x: u32, ) -> Weight {
(24_623_000 as Weight) (24_730_000 as Weight)
// Standard Error: 3_000 // Standard Error: 4_000
.saturating_add((230_000 as Weight).saturating_mul(r as Weight)) .saturating_add((196_000 as Weight).saturating_mul(r as Weight))
// Standard Error: 0 // Standard Error: 0
.saturating_add((339_000 as Weight).saturating_mul(x as Weight)) .saturating_add((341_000 as Weight).saturating_mul(x as Weight))
.saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
@@ -181,12 +199,17 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: Identity IdentityOf (r:1 w:1) // Storage: Identity IdentityOf (r:1 w:1)
// Storage: System Account (r:1 w:1) // Storage: System Account (r:1 w:1)
// Storage: Identity SuperOf (r:0 w:100) // Storage: Identity SuperOf (r:0 w:100)
fn kill_identity(r: u32, s: u32, _x: u32, ) -> Weight { /// The range of component `r` is `[1, 20]`.
(48_143_000 as Weight) /// The range of component `s` is `[1, 100]`.
// Standard Error: 8_000 /// The range of component `x` is `[1, 100]`.
.saturating_add((106_000 as Weight).saturating_mul(r as Weight)) fn kill_identity(r: u32, s: u32, x: u32, ) -> Weight {
// Standard Error: 0 (44_988_000 as Weight)
.saturating_add((1_105_000 as Weight).saturating_mul(s as Weight)) // Standard Error: 10_000
.saturating_add((201_000 as Weight).saturating_mul(r as Weight))
// Standard Error: 1_000
.saturating_add((1_126_000 as Weight).saturating_mul(s as Weight))
// Standard Error: 1_000
.saturating_add((2_000 as Weight).saturating_mul(x as Weight))
.saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight))
.saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight)))
@@ -194,38 +217,42 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity IdentityOf (r:1 w:0)
// Storage: Identity SuperOf (r:1 w:1) // Storage: Identity SuperOf (r:1 w:1)
// Storage: Identity SubsOf (r:1 w:1) // Storage: Identity SubsOf (r:1 w:1)
/// The range of component `s` is `[1, 99]`.
fn add_sub(s: u32, ) -> Weight { fn add_sub(s: u32, ) -> Weight {
(36_778_000 as Weight) (36_768_000 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((112_000 as Weight).saturating_mul(s as Weight)) .saturating_add((115_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight))
} }
// Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity IdentityOf (r:1 w:0)
// Storage: Identity SuperOf (r:1 w:1) // Storage: Identity SuperOf (r:1 w:1)
/// The range of component `s` is `[1, 100]`.
fn rename_sub(s: u32, ) -> Weight { fn rename_sub(s: u32, ) -> Weight {
(13_895_000 as Weight) (13_474_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((52_000 as Weight).saturating_mul(s as Weight)) .saturating_add((56_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
// Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity IdentityOf (r:1 w:0)
// Storage: Identity SuperOf (r:1 w:1) // Storage: Identity SuperOf (r:1 w:1)
// Storage: Identity SubsOf (r:1 w:1) // Storage: Identity SubsOf (r:1 w:1)
/// The range of component `s` is `[1, 100]`.
fn remove_sub(s: u32, ) -> Weight { fn remove_sub(s: u32, ) -> Weight {
(37_707_000 as Weight) (37_720_000 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((110_000 as Weight).saturating_mul(s as Weight)) .saturating_add((114_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight))
} }
// Storage: Identity SuperOf (r:1 w:1) // Storage: Identity SuperOf (r:1 w:1)
// Storage: Identity SubsOf (r:1 w:1) // Storage: Identity SubsOf (r:1 w:1)
/// The range of component `s` is `[1, 99]`.
fn quit_sub(s: u32, ) -> Weight { fn quit_sub(s: u32, ) -> Weight {
(26_935_000 as Weight) (26_848_000 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((106_000 as Weight).saturating_mul(s as Weight)) .saturating_add((115_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight))
} }
@@ -234,30 +261,34 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// For backwards compatibility and tests // For backwards compatibility and tests
impl WeightInfo for () { impl WeightInfo for () {
// Storage: Identity Registrars (r:1 w:1) // Storage: Identity Registrars (r:1 w:1)
/// The range of component `r` is `[1, 19]`.
fn add_registrar(r: u32, ) -> Weight { fn add_registrar(r: u32, ) -> Weight {
(16_343_000 as Weight) (16_649_000 as Weight)
// Standard Error: 5_000 // Standard Error: 5_000
.saturating_add((229_000 as Weight).saturating_mul(r as Weight)) .saturating_add((241_000 as Weight).saturating_mul(r as Weight))
.saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight))
} }
// Storage: Identity IdentityOf (r:1 w:1) // Storage: Identity IdentityOf (r:1 w:1)
/// The range of component `r` is `[1, 20]`.
/// The range of component `x` is `[1, 100]`.
fn set_identity(r: u32, x: u32, ) -> Weight { fn set_identity(r: u32, x: u32, ) -> Weight {
(32_920_000 as Weight) (31_322_000 as Weight)
// Standard Error: 8_000 // Standard Error: 10_000
.saturating_add((203_000 as Weight).saturating_mul(r as Weight)) .saturating_add((252_000 as Weight).saturating_mul(r as Weight))
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((300_000 as Weight).saturating_mul(x as Weight)) .saturating_add((312_000 as Weight).saturating_mul(x as Weight))
.saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight))
} }
// Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity IdentityOf (r:1 w:0)
// Storage: Identity SubsOf (r:1 w:1) // Storage: Identity SubsOf (r:1 w:1)
// Storage: Identity SuperOf (r:1 w:1) // Storage: Identity SuperOf (r:1 w:1)
/// The range of component `s` is `[1, 100]`.
fn set_subs_new(s: u32, ) -> Weight { fn set_subs_new(s: u32, ) -> Weight {
(31_009_000 as Weight) (30_012_000 as Weight)
// Standard Error: 1_000 // Standard Error: 2_000
.saturating_add((3_053_000 as Weight).saturating_mul(s as Weight)) .saturating_add((3_005_000 as Weight).saturating_mul(s as Weight))
.saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight))
.saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(s as Weight)))
.saturating_add(RocksDbWeight::get().writes(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight))
@@ -266,10 +297,11 @@ impl WeightInfo for () {
// Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity IdentityOf (r:1 w:0)
// Storage: Identity SubsOf (r:1 w:1) // Storage: Identity SubsOf (r:1 w:1)
// Storage: Identity SuperOf (r:0 w:1) // Storage: Identity SuperOf (r:0 w:1)
/// The range of component `p` is `[1, 100]`.
fn set_subs_old(p: u32, ) -> Weight { fn set_subs_old(p: u32, ) -> Weight {
(29_712_000 as Weight) (29_623_000 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((1_087_000 as Weight).saturating_mul(p as Weight)) .saturating_add((1_100_000 as Weight).saturating_mul(p as Weight))
.saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight))
.saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(p as Weight))) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(p as Weight)))
@@ -277,71 +309,83 @@ impl WeightInfo for () {
// Storage: Identity SubsOf (r:1 w:1) // Storage: Identity SubsOf (r:1 w:1)
// Storage: Identity IdentityOf (r:1 w:1) // Storage: Identity IdentityOf (r:1 w:1)
// Storage: Identity SuperOf (r:0 w:100) // Storage: Identity SuperOf (r:0 w:100)
/// The range of component `r` is `[1, 20]`.
/// The range of component `s` is `[1, 100]`.
/// The range of component `x` is `[1, 100]`.
fn clear_identity(r: u32, s: u32, x: u32, ) -> Weight { fn clear_identity(r: u32, s: u32, x: u32, ) -> Weight {
(33_943_000 as Weight) (34_370_000 as Weight)
// Standard Error: 7_000 // Standard Error: 10_000
.saturating_add((193_000 as Weight).saturating_mul(r as Weight)) .saturating_add((186_000 as Weight).saturating_mul(r as Weight))
// Standard Error: 0 // Standard Error: 1_000
.saturating_add((1_101_000 as Weight).saturating_mul(s as Weight)) .saturating_add((1_114_000 as Weight).saturating_mul(s as Weight))
// Standard Error: 0 // Standard Error: 1_000
.saturating_add((194_000 as Weight).saturating_mul(x as Weight)) .saturating_add((189_000 as Weight).saturating_mul(x as Weight))
.saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight))
.saturating_add(RocksDbWeight::get().writes(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight))
.saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight)))
} }
// Storage: Identity Registrars (r:1 w:0) // Storage: Identity Registrars (r:1 w:0)
// Storage: Identity IdentityOf (r:1 w:1) // Storage: Identity IdentityOf (r:1 w:1)
/// The range of component `r` is `[1, 20]`.
/// The range of component `x` is `[1, 100]`.
fn request_judgement(r: u32, x: u32, ) -> Weight { fn request_judgement(r: u32, x: u32, ) -> Weight {
(34_861_000 as Weight) (34_759_000 as Weight)
// Standard Error: 3_000 // Standard Error: 4_000
.saturating_add((249_000 as Weight).saturating_mul(r as Weight)) .saturating_add((251_000 as Weight).saturating_mul(r as Weight))
// Standard Error: 0 // Standard Error: 0
.saturating_add((344_000 as Weight).saturating_mul(x as Weight)) .saturating_add((340_000 as Weight).saturating_mul(x as Weight))
.saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight))
} }
// Storage: Identity IdentityOf (r:1 w:1) // Storage: Identity IdentityOf (r:1 w:1)
/// The range of component `r` is `[1, 20]`.
/// The range of component `x` is `[1, 100]`.
fn cancel_request(r: u32, x: u32, ) -> Weight { fn cancel_request(r: u32, x: u32, ) -> Weight {
(32_906_000 as Weight) (32_254_000 as Weight)
// Standard Error: 3_000 // Standard Error: 7_000
.saturating_add((147_000 as Weight).saturating_mul(r as Weight)) .saturating_add((159_000 as Weight).saturating_mul(r as Weight))
// Standard Error: 0 // Standard Error: 0
.saturating_add((341_000 as Weight).saturating_mul(x as Weight)) .saturating_add((347_000 as Weight).saturating_mul(x as Weight))
.saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight))
} }
// Storage: Identity Registrars (r:1 w:1) // Storage: Identity Registrars (r:1 w:1)
/// The range of component `r` is `[1, 19]`.
fn set_fee(r: u32, ) -> Weight { fn set_fee(r: u32, ) -> Weight {
(7_591_000 as Weight) (7_858_000 as Weight)
// Standard Error: 3_000 // Standard Error: 3_000
.saturating_add((201_000 as Weight).saturating_mul(r as Weight)) .saturating_add((190_000 as Weight).saturating_mul(r as Weight))
.saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight))
} }
// Storage: Identity Registrars (r:1 w:1) // Storage: Identity Registrars (r:1 w:1)
/// The range of component `r` is `[1, 19]`.
fn set_account_id(r: u32, ) -> Weight { fn set_account_id(r: u32, ) -> Weight {
(7_919_000 as Weight) (8_011_000 as Weight)
// Standard Error: 3_000 // Standard Error: 3_000
.saturating_add((183_000 as Weight).saturating_mul(r as Weight)) .saturating_add((187_000 as Weight).saturating_mul(r as Weight))
.saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight))
} }
// Storage: Identity Registrars (r:1 w:1) // Storage: Identity Registrars (r:1 w:1)
/// The range of component `r` is `[1, 19]`.
fn set_fields(r: u32, ) -> Weight { fn set_fields(r: u32, ) -> Weight {
(7_887_000 as Weight) (7_970_000 as Weight)
// Standard Error: 4_000 // Standard Error: 3_000
.saturating_add((182_000 as Weight).saturating_mul(r as Weight)) .saturating_add((175_000 as Weight).saturating_mul(r as Weight))
.saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight))
} }
// Storage: Identity Registrars (r:1 w:0) // Storage: Identity Registrars (r:1 w:0)
// Storage: Identity IdentityOf (r:1 w:1) // Storage: Identity IdentityOf (r:1 w:1)
/// The range of component `r` is `[1, 19]`.
/// The range of component `x` is `[1, 100]`.
fn provide_judgement(r: u32, x: u32, ) -> Weight { fn provide_judgement(r: u32, x: u32, ) -> Weight {
(24_623_000 as Weight) (24_730_000 as Weight)
// Standard Error: 3_000 // Standard Error: 4_000
.saturating_add((230_000 as Weight).saturating_mul(r as Weight)) .saturating_add((196_000 as Weight).saturating_mul(r as Weight))
// Standard Error: 0 // Standard Error: 0
.saturating_add((339_000 as Weight).saturating_mul(x as Weight)) .saturating_add((341_000 as Weight).saturating_mul(x as Weight))
.saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight))
} }
@@ -349,12 +393,17 @@ impl WeightInfo for () {
// Storage: Identity IdentityOf (r:1 w:1) // Storage: Identity IdentityOf (r:1 w:1)
// Storage: System Account (r:1 w:1) // Storage: System Account (r:1 w:1)
// Storage: Identity SuperOf (r:0 w:100) // Storage: Identity SuperOf (r:0 w:100)
fn kill_identity(r: u32, s: u32, _x: u32, ) -> Weight { /// The range of component `r` is `[1, 20]`.
(48_143_000 as Weight) /// The range of component `s` is `[1, 100]`.
// Standard Error: 8_000 /// The range of component `x` is `[1, 100]`.
.saturating_add((106_000 as Weight).saturating_mul(r as Weight)) fn kill_identity(r: u32, s: u32, x: u32, ) -> Weight {
// Standard Error: 0 (44_988_000 as Weight)
.saturating_add((1_105_000 as Weight).saturating_mul(s as Weight)) // Standard Error: 10_000
.saturating_add((201_000 as Weight).saturating_mul(r as Weight))
// Standard Error: 1_000
.saturating_add((1_126_000 as Weight).saturating_mul(s as Weight))
// Standard Error: 1_000
.saturating_add((2_000 as Weight).saturating_mul(x as Weight))
.saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().reads(3 as Weight))
.saturating_add(RocksDbWeight::get().writes(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight))
.saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight)))
@@ -362,38 +411,42 @@ impl WeightInfo for () {
// Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity IdentityOf (r:1 w:0)
// Storage: Identity SuperOf (r:1 w:1) // Storage: Identity SuperOf (r:1 w:1)
// Storage: Identity SubsOf (r:1 w:1) // Storage: Identity SubsOf (r:1 w:1)
/// The range of component `s` is `[1, 99]`.
fn add_sub(s: u32, ) -> Weight { fn add_sub(s: u32, ) -> Weight {
(36_778_000 as Weight) (36_768_000 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((112_000 as Weight).saturating_mul(s as Weight)) .saturating_add((115_000 as Weight).saturating_mul(s as Weight))
.saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().reads(3 as Weight))
.saturating_add(RocksDbWeight::get().writes(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight))
} }
// Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity IdentityOf (r:1 w:0)
// Storage: Identity SuperOf (r:1 w:1) // Storage: Identity SuperOf (r:1 w:1)
/// The range of component `s` is `[1, 100]`.
fn rename_sub(s: u32, ) -> Weight { fn rename_sub(s: u32, ) -> Weight {
(13_895_000 as Weight) (13_474_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((52_000 as Weight).saturating_mul(s as Weight)) .saturating_add((56_000 as Weight).saturating_mul(s as Weight))
.saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight))
} }
// Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity IdentityOf (r:1 w:0)
// Storage: Identity SuperOf (r:1 w:1) // Storage: Identity SuperOf (r:1 w:1)
// Storage: Identity SubsOf (r:1 w:1) // Storage: Identity SubsOf (r:1 w:1)
/// The range of component `s` is `[1, 100]`.
fn remove_sub(s: u32, ) -> Weight { fn remove_sub(s: u32, ) -> Weight {
(37_707_000 as Weight) (37_720_000 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((110_000 as Weight).saturating_mul(s as Weight)) .saturating_add((114_000 as Weight).saturating_mul(s as Weight))
.saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().reads(3 as Weight))
.saturating_add(RocksDbWeight::get().writes(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight))
} }
// Storage: Identity SuperOf (r:1 w:1) // Storage: Identity SuperOf (r:1 w:1)
// Storage: Identity SubsOf (r:1 w:1) // Storage: Identity SubsOf (r:1 w:1)
/// The range of component `s` is `[1, 99]`.
fn quit_sub(s: u32, ) -> Weight { fn quit_sub(s: u32, ) -> Weight {
(26_935_000 as Weight) (26_848_000 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((106_000 as Weight).saturating_mul(s as Weight)) .saturating_add((115_000 as Weight).saturating_mul(s as Weight))
.saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight))
.saturating_add(RocksDbWeight::get().writes(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight))
} }
+12 -2
View File
@@ -57,9 +57,11 @@ pub trait WeightInfo {
/// Weights for frame_system using the Substrate node and recommended hardware. /// Weights for frame_system using the Substrate node and recommended hardware.
pub struct SubstrateWeight<T>(PhantomData<T>); pub struct SubstrateWeight<T>(PhantomData<T>);
impl<T: crate::Config> WeightInfo for SubstrateWeight<T> { impl<T: crate::Config> WeightInfo for SubstrateWeight<T> {
/// The range of component `b` is `[0, 3932160]`.
fn remark(_b: u32, ) -> Weight { fn remark(_b: u32, ) -> Weight {
(0 as Weight) (1_000_000 as Weight)
} }
/// The range of component `b` is `[0, 3932160]`.
fn remark_with_event(b: u32, ) -> Weight { fn remark_with_event(b: u32, ) -> Weight {
(0 as Weight) (0 as Weight)
// Standard Error: 0 // Standard Error: 0
@@ -73,6 +75,7 @@ impl<T: crate::Config> WeightInfo for SubstrateWeight<T> {
.saturating_add(T::DbWeight::get().writes(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight))
} }
// Storage: Skipped Metadata (r:0 w:0) // Storage: Skipped Metadata (r:0 w:0)
/// The range of component `i` is `[1, 1000]`.
fn set_storage(i: u32, ) -> Weight { fn set_storage(i: u32, ) -> Weight {
(0 as Weight) (0 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
@@ -80,6 +83,7 @@ impl<T: crate::Config> WeightInfo for SubstrateWeight<T> {
.saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight)))
} }
// Storage: Skipped Metadata (r:0 w:0) // Storage: Skipped Metadata (r:0 w:0)
/// The range of component `i` is `[1, 1000]`.
fn kill_storage(i: u32, ) -> Weight { fn kill_storage(i: u32, ) -> Weight {
(0 as Weight) (0 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
@@ -87,6 +91,7 @@ impl<T: crate::Config> WeightInfo for SubstrateWeight<T> {
.saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight)))
} }
// Storage: Skipped Metadata (r:0 w:0) // Storage: Skipped Metadata (r:0 w:0)
/// The range of component `p` is `[1, 1000]`.
fn kill_prefix(p: u32, ) -> Weight { fn kill_prefix(p: u32, ) -> Weight {
(0 as Weight) (0 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
@@ -97,9 +102,11 @@ impl<T: crate::Config> WeightInfo for SubstrateWeight<T> {
// For backwards compatibility and tests // For backwards compatibility and tests
impl WeightInfo for () { impl WeightInfo for () {
/// The range of component `b` is `[0, 3932160]`.
fn remark(_b: u32, ) -> Weight { fn remark(_b: u32, ) -> Weight {
(0 as Weight) (1_000_000 as Weight)
} }
/// The range of component `b` is `[0, 3932160]`.
fn remark_with_event(b: u32, ) -> Weight { fn remark_with_event(b: u32, ) -> Weight {
(0 as Weight) (0 as Weight)
// Standard Error: 0 // Standard Error: 0
@@ -113,6 +120,7 @@ impl WeightInfo for () {
.saturating_add(RocksDbWeight::get().writes(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight))
} }
// Storage: Skipped Metadata (r:0 w:0) // Storage: Skipped Metadata (r:0 w:0)
/// The range of component `i` is `[1, 1000]`.
fn set_storage(i: u32, ) -> Weight { fn set_storage(i: u32, ) -> Weight {
(0 as Weight) (0 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
@@ -120,6 +128,7 @@ impl WeightInfo for () {
.saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(i as Weight)))
} }
// Storage: Skipped Metadata (r:0 w:0) // Storage: Skipped Metadata (r:0 w:0)
/// The range of component `i` is `[1, 1000]`.
fn kill_storage(i: u32, ) -> Weight { fn kill_storage(i: u32, ) -> Weight {
(0 as Weight) (0 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
@@ -127,6 +136,7 @@ impl WeightInfo for () {
.saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(i as Weight)))
} }
// Storage: Skipped Metadata (r:0 w:0) // Storage: Skipped Metadata (r:0 w:0)
/// The range of component `p` is `[1, 1000]`.
fn kill_prefix(p: u32, ) -> Weight { fn kill_prefix(p: u32, ) -> Weight {
(0 as Weight) (0 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
+3 -2
View File
@@ -119,8 +119,9 @@ for PALLET in "${PALLETS[@]}"; do
--extrinsic="*" \ --extrinsic="*" \
--execution=wasm \ --execution=wasm \
--wasm-execution=compiled \ --wasm-execution=compiled \
--template=./.maintain/frame-weight-template.hbs \ --heap-pages=4096 \
--output="$WEIGHT_FILE" 2>&1 --output="$WEIGHT_FILE" \
--template=./.maintain/frame-weight-template.hbs 2>&1
) )
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "$OUTPUT" >> "$ERR_FILE" echo "$OUTPUT" >> "$ERR_FILE"
@@ -29,6 +29,7 @@ use sc_cli::{
use sc_client_db::BenchmarkingState; use sc_client_db::BenchmarkingState;
use sc_executor::NativeElseWasmExecutor; use sc_executor::NativeElseWasmExecutor;
use sc_service::{Configuration, NativeExecutionDispatch}; use sc_service::{Configuration, NativeExecutionDispatch};
use serde::Serialize;
use sp_core::offchain::{ use sp_core::offchain::{
testing::{TestOffchainExt, TestTransactionPoolExt}, testing::{TestOffchainExt, TestTransactionPoolExt},
OffchainDbExt, OffchainWorkerExt, TransactionPoolExt, OffchainDbExt, OffchainWorkerExt, TransactionPoolExt,
@@ -37,7 +38,18 @@ use sp_externalities::Extensions;
use sp_keystore::{testing::KeyStore, KeystoreExt, SyncCryptoStorePtr}; use sp_keystore::{testing::KeyStore, KeystoreExt, SyncCryptoStorePtr};
use sp_runtime::traits::{Block as BlockT, Header as HeaderT}; use sp_runtime::traits::{Block as BlockT, Header as HeaderT};
use sp_state_machine::StateMachine; use sp_state_machine::StateMachine;
use std::{fmt::Debug, fs, sync::Arc, time}; use std::{collections::HashMap, fmt::Debug, fs, sync::Arc, time};
/// The inclusive range of a component.
#[derive(Serialize, Debug, Clone, Eq, PartialEq)]
pub(crate) struct ComponentRange {
/// Name of the component.
name: String,
/// Minimal valid value of the component.
min: u32,
/// Maximal valid value of the component.
max: u32,
}
// This takes multiple benchmark batches and combines all the results where the pallet, instance, // This takes multiple benchmark batches and combines all the results where the pallet, instance,
// and benchmark are the same. // and benchmark are the same.
@@ -212,6 +224,9 @@ impl PalletCmd {
let mut batches = Vec::new(); let mut batches = Vec::new();
let mut batches_db = Vec::new(); let mut batches_db = Vec::new();
let mut timer = time::SystemTime::now(); let mut timer = time::SystemTime::now();
// Maps (pallet, extrinsic) to its component ranges.
let mut component_ranges = HashMap::<(Vec<u8>, Vec<u8>), Vec<ComponentRange>>::new();
for (pallet, extrinsic, components) in benchmarks_to_run { for (pallet, extrinsic, components) in benchmarks_to_run {
let all_components = if components.is_empty() { let all_components = if components.is_empty() {
vec![Default::default()] vec![Default::default()]
@@ -244,6 +259,11 @@ impl PalletCmd {
.collect(); .collect();
all_components.push(c); all_components.push(c);
} }
component_ranges
.entry((pallet.clone(), extrinsic.clone()))
.or_default()
.push(ComponentRange { name: name.to_string(), min: lowest, max: highest });
} }
all_components all_components
}; };
@@ -366,7 +386,7 @@ impl PalletCmd {
// Create the weights.rs file. // Create the weights.rs file.
if let Some(output_path) = &self.output { if let Some(output_path) = &self.output {
writer::write_results(&batches, &storage_info, output_path, self)?; writer::write_results(&batches, &storage_info, &component_ranges, output_path, self)?;
} }
// Jsonify the result and write it to a file or stdout if desired. // Jsonify the result and write it to a file or stdout if desired.
@@ -25,6 +25,9 @@ impl<T: frame_system::Config> {{pallet}}::WeightInfo for WeightInfo<T> {
{{#each benchmark.comments as |comment|}} {{#each benchmark.comments as |comment|}}
// {{comment}} // {{comment}}
{{/each}} {{/each}}
{{#each benchmark.component_ranges as |range|}}
/// The range of component `{{range.name}}` is `[{{range.min}}, {{range.max}}]`.
{{/each}}
fn {{benchmark.name~}} fn {{benchmark.name~}}
( (
{{~#each benchmark.components as |c| ~}} {{~#each benchmark.components as |c| ~}}
@@ -26,7 +26,7 @@ use std::{
use inflector::Inflector; use inflector::Inflector;
use serde::Serialize; use serde::Serialize;
use crate::{shared::UnderscoreHelper, PalletCmd}; use crate::{pallet::command::ComponentRange, shared::UnderscoreHelper, PalletCmd};
use frame_benchmarking::{ use frame_benchmarking::{
Analysis, AnalysisChoice, BenchmarkBatchSplitResults, BenchmarkResult, BenchmarkSelector, Analysis, AnalysisChoice, BenchmarkBatchSplitResults, BenchmarkResult, BenchmarkSelector,
RegressionModel, RegressionModel,
@@ -67,6 +67,7 @@ struct BenchmarkData {
component_weight: Vec<ComponentSlope>, component_weight: Vec<ComponentSlope>,
component_reads: Vec<ComponentSlope>, component_reads: Vec<ComponentSlope>,
component_writes: Vec<ComponentSlope>, component_writes: Vec<ComponentSlope>,
component_ranges: Vec<ComponentRange>,
comments: Vec<String>, comments: Vec<String>,
} }
@@ -118,6 +119,7 @@ fn io_error(s: &str) -> std::io::Error {
fn map_results( fn map_results(
batches: &[BenchmarkBatchSplitResults], batches: &[BenchmarkBatchSplitResults],
storage_info: &[StorageInfo], storage_info: &[StorageInfo],
component_ranges: &HashMap<(Vec<u8>, Vec<u8>), Vec<ComponentRange>>,
analysis_choice: &AnalysisChoice, analysis_choice: &AnalysisChoice,
) -> Result<HashMap<(String, String), Vec<BenchmarkData>>, std::io::Error> { ) -> Result<HashMap<(String, String), Vec<BenchmarkData>>, std::io::Error> {
// Skip if batches is empty. // Skip if batches is empty.
@@ -135,7 +137,8 @@ fn map_results(
let pallet_string = String::from_utf8(batch.pallet.clone()).unwrap(); let pallet_string = String::from_utf8(batch.pallet.clone()).unwrap();
let instance_string = String::from_utf8(batch.instance.clone()).unwrap(); let instance_string = String::from_utf8(batch.instance.clone()).unwrap();
let benchmark_data = get_benchmark_data(batch, storage_info, analysis_choice); let benchmark_data =
get_benchmark_data(batch, storage_info, &component_ranges, analysis_choice);
let pallet_benchmarks = all_benchmarks.entry((pallet_string, instance_string)).or_default(); let pallet_benchmarks = all_benchmarks.entry((pallet_string, instance_string)).or_default();
pallet_benchmarks.push(benchmark_data); pallet_benchmarks.push(benchmark_data);
} }
@@ -155,6 +158,8 @@ fn extract_errors(model: &Option<RegressionModel>) -> impl Iterator<Item = u128>
fn get_benchmark_data( fn get_benchmark_data(
batch: &BenchmarkBatchSplitResults, batch: &BenchmarkBatchSplitResults,
storage_info: &[StorageInfo], storage_info: &[StorageInfo],
// Per extrinsic component ranges.
component_ranges: &HashMap<(Vec<u8>, Vec<u8>), Vec<ComponentRange>>,
analysis_choice: &AnalysisChoice, analysis_choice: &AnalysisChoice,
) -> BenchmarkData { ) -> BenchmarkData {
// You can use this to put any additional comments with the benchmarking output. // You can use this to put any additional comments with the benchmarking output.
@@ -238,6 +243,10 @@ fn get_benchmark_data(
// We add additional comments showing which storage items were touched. // We add additional comments showing which storage items were touched.
add_storage_comments(&mut comments, &batch.db_results, storage_info); add_storage_comments(&mut comments, &batch.db_results, storage_info);
let component_ranges = component_ranges
.get(&(batch.pallet.clone(), batch.benchmark.clone()))
.map(|c| c.clone())
.unwrap_or_default();
BenchmarkData { BenchmarkData {
name: String::from_utf8(batch.benchmark.clone()).unwrap(), name: String::from_utf8(batch.benchmark.clone()).unwrap(),
@@ -248,14 +257,16 @@ fn get_benchmark_data(
component_weight: used_extrinsic_time, component_weight: used_extrinsic_time,
component_reads: used_reads, component_reads: used_reads,
component_writes: used_writes, component_writes: used_writes,
component_ranges,
comments, comments,
} }
} }
// Create weight file from benchmark data and Handlebars template. // Create weight file from benchmark data and Handlebars template.
pub fn write_results( pub(crate) fn write_results(
batches: &[BenchmarkBatchSplitResults], batches: &[BenchmarkBatchSplitResults],
storage_info: &[StorageInfo], storage_info: &[StorageInfo],
component_ranges: &HashMap<(Vec<u8>, Vec<u8>), Vec<ComponentRange>>,
path: &PathBuf, path: &PathBuf,
cmd: &PalletCmd, cmd: &PalletCmd,
) -> Result<(), std::io::Error> { ) -> Result<(), std::io::Error> {
@@ -305,7 +316,7 @@ pub fn write_results(
handlebars.register_escape_fn(|s| -> String { s.to_string() }); handlebars.register_escape_fn(|s| -> String { s.to_string() });
// Organize results by pallet into a JSON map // Organize results by pallet into a JSON map
let all_results = map_results(batches, storage_info, &analysis_choice)?; let all_results = map_results(batches, storage_info, component_ranges, &analysis_choice)?;
for ((pallet, instance), results) in all_results.iter() { for ((pallet, instance), results) in all_results.iter() {
let mut file_path = path.clone(); let mut file_path = path.clone();
// If a user only specified a directory... // If a user only specified a directory...
@@ -531,6 +542,7 @@ mod test {
test_data(b"second", b"first", BenchmarkParameter::c, 3, 4), test_data(b"second", b"first", BenchmarkParameter::c, 3, 4),
], ],
&[], &[],
&Default::default(),
&AnalysisChoice::default(), &AnalysisChoice::default(),
) )
.unwrap(); .unwrap();