mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-23 09:41:07 +00:00
Benchmark Democracy Pallet (#5257)
* Add origin bounds to benchmark macro. * Add democracy benchmark. * Fix tests * Remove collective from frame/benchmarking, partially use EnsureOrigin. * Remove collective stuff. * Make previous benches compile again. * Remove comments. * Make prev bench to work again. * Add remove votes. * Add new proxy calls. * Add runtime-benchmarks guard to EnsureOrigin and implementations. * Refactor. * Add missing import. * Remove duplicated import * Fix features. * Add some missing features. * Update frame/collective/Cargo.toml Co-Authored-By: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Update frame/democracy/src/benchmarking.rs Co-Authored-By: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Update frame/democracy/src/benchmarking.rs Co-Authored-By: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Add referendums to state. * populate vecs before call * Update weight docs * More fixes and weight docs * More updates Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
@@ -190,6 +190,9 @@ pub use types::{ReferendumInfo, ReferendumStatus, ProxyState, Tally, UnvoteScope
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
pub mod benchmarking;
|
||||
|
||||
const DEMOCRACY_ID: LockIdentifier = *b"democrac";
|
||||
|
||||
/// A proposal index.
|
||||
@@ -516,7 +519,8 @@ decl_module! {
|
||||
/// Emits `Proposed`.
|
||||
///
|
||||
/// # <weight>
|
||||
/// - `O(1)`.
|
||||
/// - `O(P)`
|
||||
/// - P is the number proposals in the `PublicProps` vec.
|
||||
/// - Two DB changes, one DB entry.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(5_000_000)]
|
||||
@@ -546,7 +550,8 @@ decl_module! {
|
||||
/// - `proposal`: The index of the proposal to second.
|
||||
///
|
||||
/// # <weight>
|
||||
/// - `O(1)`.
|
||||
/// - `O(S)`.
|
||||
/// - S is the number of seconds a proposal already has.
|
||||
/// - One DB entry.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(5_000_000)]
|
||||
@@ -568,7 +573,8 @@ decl_module! {
|
||||
/// - `vote`: The vote configuration.
|
||||
///
|
||||
/// # <weight>
|
||||
/// - `O(1)`.
|
||||
/// - `O(R)`.
|
||||
/// - R is the number of referendums the voter has voted on.
|
||||
/// - One DB change, one DB entry.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(200_000)]
|
||||
@@ -610,7 +616,7 @@ decl_module! {
|
||||
/// -`ref_index`: The index of the referendum to cancel.
|
||||
///
|
||||
/// # <weight>
|
||||
/// - Depends on size of storage vec `VotersFor` for this referendum.
|
||||
/// - `O(1)`.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(500_000)]
|
||||
fn emergency_cancel(origin, ref_index: ReferendumIndex) {
|
||||
@@ -756,6 +762,7 @@ decl_module! {
|
||||
/// - One DB clear.
|
||||
/// - Performs a binary search on `existing_vetoers` which should not
|
||||
/// be very large.
|
||||
/// - O(log v), v is number of `existing_vetoers`
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(200_000)]
|
||||
fn veto_external(origin, proposal_hash: T::Hash) {
|
||||
@@ -804,6 +811,7 @@ decl_module! {
|
||||
///
|
||||
/// # <weight>
|
||||
/// - One DB change.
|
||||
/// - O(d) where d is the items in the dispatch queue.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(10_000)]
|
||||
fn cancel_queued(origin, which: ReferendumIndex) {
|
||||
@@ -993,7 +1001,7 @@ decl_module! {
|
||||
/// Emits `PreimageNoted`.
|
||||
///
|
||||
/// # <weight>
|
||||
/// - Dependent on the size of `encoded_proposal`.
|
||||
/// - Dependent on the size of `encoded_proposal` and length of dispatch queue.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(100_000)]
|
||||
fn note_imminent_preimage(origin, encoded_proposal: Vec<u8>) {
|
||||
|
||||
Reference in New Issue
Block a user