mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 09:57:56 +00:00
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:
committed by
GitHub
parent
a2afadb123
commit
eb4be02155
@@ -29,6 +29,7 @@ use sc_cli::{
|
||||
use sc_client_db::BenchmarkingState;
|
||||
use sc_executor::NativeElseWasmExecutor;
|
||||
use sc_service::{Configuration, NativeExecutionDispatch};
|
||||
use serde::Serialize;
|
||||
use sp_core::offchain::{
|
||||
testing::{TestOffchainExt, TestTransactionPoolExt},
|
||||
OffchainDbExt, OffchainWorkerExt, TransactionPoolExt,
|
||||
@@ -37,7 +38,18 @@ use sp_externalities::Extensions;
|
||||
use sp_keystore::{testing::KeyStore, KeystoreExt, SyncCryptoStorePtr};
|
||||
use sp_runtime::traits::{Block as BlockT, Header as HeaderT};
|
||||
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,
|
||||
// and benchmark are the same.
|
||||
@@ -212,6 +224,9 @@ impl PalletCmd {
|
||||
let mut batches = Vec::new();
|
||||
let mut batches_db = Vec::new();
|
||||
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 {
|
||||
let all_components = if components.is_empty() {
|
||||
vec![Default::default()]
|
||||
@@ -244,6 +259,11 @@ impl PalletCmd {
|
||||
.collect();
|
||||
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
|
||||
};
|
||||
@@ -366,7 +386,7 @@ impl PalletCmd {
|
||||
|
||||
// Create the weights.rs file.
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user