mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 21:17:56 +00:00
30e7b1e8cd
* Create sp-weights crate to store weight primitives * Fix templates * Fix templates * Fixes * Fixes * cargo fmt * Fixes * Fixes * Use deprecated type alias instead of deprecated unit types * Use deprecated subtraits instead of deprecated hollow new traits * Fixes * Allow deprecation in macro expansion * Add missing where clause during call macro expansion * cargo fmt * Fixes * cargo fmt * Fixes * Fixes * Fixes * Fixes * Move FRAME-specific weight files back to frame_support * Fixes * Update frame/support/src/dispatch.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Update frame/support/src/dispatch.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Update frame/support/src/dispatch.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Add missing header * Rewrite module docs * Fixes * Fixes * Fixes * Fixes * cargo fmt Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
65 lines
2.3 KiB
Handlebars
65 lines
2.3 KiB
Handlebars
{{header}}
|
|
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION {{version}}
|
|
//! DATE: {{date}}
|
|
//! HOSTNAME: `{{hostname}}`, CPU: `{{cpuname}}`
|
|
//!
|
|
//! SHORT-NAME: `{{short_name}}`, LONG-NAME: `{{long_name}}`, RUNTIME: `{{runtime_name}}`
|
|
//! WARMUPS: `{{params.bench.warmup}}`, REPEAT: `{{params.bench.repeat}}`
|
|
//! WEIGHT-PATH: `{{params.weight.weight_path}}`
|
|
//! WEIGHT-METRIC: `{{params.weight.weight_metric}}`, WEIGHT-MUL: `{{params.weight.weight_mul}}`, WEIGHT-ADD: `{{params.weight.weight_add}}`
|
|
|
|
// Executed Command:
|
|
{{#each args as |arg|}}
|
|
// {{arg}}
|
|
{{/each}}
|
|
|
|
use sp_core::parameter_types;
|
|
use sp_weights::{constants::WEIGHT_PER_NANOS, Weight};
|
|
|
|
parameter_types! {
|
|
{{#if (eq short_name "block")}}
|
|
/// Time to execute an empty block.
|
|
{{else}}
|
|
/// Time to execute a NO-OP extrinsic, for example `System::remark`.
|
|
{{/if}}
|
|
/// Calculated by multiplying the *{{params.weight.weight_metric}}* with `{{params.weight.weight_mul}}` and adding `{{params.weight.weight_add}}`.
|
|
///
|
|
/// Stats nanoseconds:
|
|
/// Min, Max: {{underscore stats.min}}, {{underscore stats.max}}
|
|
/// Average: {{underscore stats.avg}}
|
|
/// Median: {{underscore stats.median}}
|
|
/// Std-Dev: {{stats.stddev}}
|
|
///
|
|
/// Percentiles nanoseconds:
|
|
/// 99th: {{underscore stats.p99}}
|
|
/// 95th: {{underscore stats.p95}}
|
|
/// 75th: {{underscore stats.p75}}
|
|
pub const {{long_name}}Weight: Weight = WEIGHT_PER_NANOS.saturating_mul({{underscore weight}});
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod test_weights {
|
|
use super::*;
|
|
use sp_weights::constants;
|
|
|
|
/// Checks that the weight exists and is sane.
|
|
// NOTE: If this test fails but you are sure that the generated values are fine,
|
|
// you can delete it.
|
|
#[test]
|
|
fn sane() {
|
|
let w = super::{{long_name}}Weight::get();
|
|
|
|
{{#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.");
|
|
// 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.");
|
|
// At most 1 ms.
|
|
assert!(w.ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(), "Weight should be at most 1 ms.");
|
|
{{/if}}
|
|
}
|
|
}
|