mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 11:41:04 +00:00
Make election benchmarks more *memory-aware* (#9286)
* Make benchmarks a bit better with mem * Make election benchmarks more *memory-aware* * Fix a few errors * cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_election_provider_multi_phase --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/election-provider-multi-phase/src/weights.rs --template=./.maintain/frame-weight-template.hbs * Manually fix the weights * Update lock file * remove dupe * Fix tests * cargo update pwasm Co-authored-by: Parity Bot <admin@parity.io>
This commit is contained in:
@@ -3049,6 +3049,57 @@ impl<T: Config> frame_election_provider_support::ElectionDataProvider<T::Account
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "runtime-benchmarks", test))]
|
||||
fn add_voter(voter: T::AccountId, weight: VoteWeight, targets: Vec<T::AccountId>) {
|
||||
use sp_std::convert::TryFrom;
|
||||
let stake = <BalanceOf<T>>::try_from(weight).unwrap_or_else(|_| {
|
||||
panic!("cannot convert a VoteWeight into BalanceOf, benchmark needs reconfiguring.")
|
||||
});
|
||||
<Bonded<T>>::insert(voter.clone(), voter.clone());
|
||||
<Ledger<T>>::insert(
|
||||
voter.clone(),
|
||||
StakingLedger {
|
||||
stash: voter.clone(),
|
||||
active: stake,
|
||||
total: stake,
|
||||
unlocking: vec![],
|
||||
claimed_rewards: vec![],
|
||||
},
|
||||
);
|
||||
Self::do_add_nominator(
|
||||
&voter,
|
||||
Nominations { targets: targets, submitted_in: 0, suppressed: false },
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "runtime-benchmarks", test))]
|
||||
fn add_target(target: T::AccountId) {
|
||||
let stake = MinValidatorBond::<T>::get() * 100u32.into();
|
||||
<Bonded<T>>::insert(target.clone(), target.clone());
|
||||
<Ledger<T>>::insert(
|
||||
target.clone(),
|
||||
StakingLedger {
|
||||
stash: target.clone(),
|
||||
active: stake,
|
||||
total: stake,
|
||||
unlocking: vec![],
|
||||
claimed_rewards: vec![],
|
||||
},
|
||||
);
|
||||
Self::do_add_validator(
|
||||
&target,
|
||||
ValidatorPrefs { commission: Perbill::zero(), blocked: false },
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "runtime-benchmarks", test))]
|
||||
fn clear() {
|
||||
<Bonded<T>>::remove_all(None);
|
||||
<Ledger<T>>::remove_all(None);
|
||||
<Validators<T>>::remove_all(None);
|
||||
<Nominators<T>>::remove_all(None);
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "runtime-benchmarks", test))]
|
||||
fn put_snapshot(
|
||||
voters: Vec<(T::AccountId, VoteWeight, Vec<T::AccountId>)>,
|
||||
|
||||
Reference in New Issue
Block a user