Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Format templates and fix --steps default value #12286

Merged
merged 3 commits into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions utils/frame/benchmarking-cli/src/overhead/weights.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ parameter_types! {

#[cfg(test)]
mod test_weights {
use super::*;
use sp_weights::constants;

/// Checks that the weight exists and is sane.
Expand All @@ -51,14 +50,26 @@ mod test_weights {

{{#if (eq short_name "block")}}
// At least 100 µs.
assert!(w.ref_time() >= 100u64 * constants::WEIGHT_PER_MICROS.ref_time(), "Weight should be at least 100 µs.");
assert!(
w.ref_time() >= 100u64 * constants::WEIGHT_PER_MICROS.ref_time(),
"Weight should be at least 100 µs."
);
// At most 50 ms.
assert!(w.ref_time() <= 50u64 * constants::WEIGHT_PER_MILLIS.ref_time(), "Weight should be at most 50 ms.");
assert!(
w.ref_time() <= 50u64 * constants::WEIGHT_PER_MILLIS.ref_time(),
"Weight should be at most 50 ms."
);
{{else}}
// At least 10 µs.
assert!(w.ref_time() >= 10u64 * constants::WEIGHT_PER_MICROS.ref_time(), "Weight should be at least 10 µs.");
assert!(
w.ref_time() >= 10u64 * constants::WEIGHT_PER_MICROS.ref_time(),
"Weight should be at least 10 µs."
);
// At most 1 ms.
assert!(w.ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(), "Weight should be at most 1 ms.");
assert!(
w.ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
"Weight should be at most 1 ms."
);
{{/if}}
}
}
2 changes: 1 addition & 1 deletion utils/frame/benchmarking-cli/src/pallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub struct PalletCmd {
pub extrinsic: Option<String>,

/// Select how many samples we should take across the variable components.
#[clap(short, long, default_value = "1")]
#[clap(short, long, default_value = "2")]
pub steps: u32,

/// Indicates lowest values for each of the component ranges.
Expand Down
2 changes: 1 addition & 1 deletion utils/frame/benchmarking-cli/src/pallet/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#![allow(unused_parens)]
#![allow(unused_imports)]

use frame_support::{traits::Get, weights::{Weight}};
use frame_support::{traits::Get, weights::Weight};
use sp_std::marker::PhantomData;

/// Weight functions for `{{pallet}}`.
Expand Down