|
| 1 | +{{header}} |
| 2 | +//! Autogenerated weights for {{pallet}} |
| 3 | +//! |
| 4 | +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION {{version}} |
| 5 | +//! DATE: {{date}}, STEPS: `{{cmd.steps}}`, REPEAT: {{cmd.repeat}}, LOW RANGE: `{{cmd.lowest_range_values}}`, HIGH RANGE: `{{cmd.highest_range_values}}` |
| 6 | +//! HOSTNAME: `{{hostname}}`, CPU: `{{cpuname}}` |
| 7 | +//! EXECUTION: {{cmd.execution}}, WASM-EXECUTION: {{cmd.wasm_execution}}, CHAIN: {{cmd.chain}}, DB CACHE: {{cmd.db_cache}} |
| 8 | + |
| 9 | +// Executed Command: |
| 10 | +{{#each args as |arg|}} |
| 11 | +// {{arg}} |
| 12 | +{{/each}} |
| 13 | + |
| 14 | +#![cfg_attr(rustfmt, rustfmt_skip)] |
| 15 | +#![allow(unused_parens)] |
| 16 | +#![allow(unused_imports)] |
| 17 | + |
| 18 | +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; |
| 19 | +use sp_std::marker::PhantomData; |
| 20 | + |
| 21 | +/// Weight functions needed for {{pallet}}. |
| 22 | +pub trait WeightInfo { |
| 23 | + {{#each benchmarks as |benchmark|}} |
| 24 | + fn {{benchmark.name~}} |
| 25 | + ( |
| 26 | + {{~#each benchmark.components as |c| ~}} |
| 27 | + {{c.name}}: u32, {{/each~}} |
| 28 | + ) -> Weight; |
| 29 | + {{/each}} |
| 30 | +} |
| 31 | + |
| 32 | +/// Weights for {{pallet}} using the Substrate node and recommended hardware. |
| 33 | +pub struct SubstrateWeight<T>(PhantomData<T>); |
| 34 | +{{#if (eq pallet "frame_system")}} |
| 35 | +impl<T: crate::Config> WeightInfo for SubstrateWeight<T> { |
| 36 | +{{else}} |
| 37 | +impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> { |
| 38 | +{{/if}} |
| 39 | + {{#each benchmarks as |benchmark|}} |
| 40 | + {{#each benchmark.comments as |comment|}} |
| 41 | + // {{comment}} |
| 42 | + {{/each}} |
| 43 | + {{#each benchmark.component_ranges as |range|}} |
| 44 | + /// The range of component `{{range.name}}` is `[{{range.min}}, {{range.max}}]`. |
| 45 | + {{/each}} |
| 46 | + fn {{benchmark.name~}} |
| 47 | + ( |
| 48 | + {{~#each benchmark.components as |c| ~}} |
| 49 | + {{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}} |
| 50 | + ) -> Weight { |
| 51 | + // Minimum execution time: {{underscore benchmark.min_execution_time}} nanoseconds. |
| 52 | + Weight::from_ref_time({{underscore benchmark.base_weight}}) |
| 53 | + {{#each benchmark.component_weight as |cw|}} |
| 54 | + // Standard Error: {{underscore cw.error}} |
| 55 | + .saturating_add(Weight::from_ref_time({{underscore cw.slope}}).saturating_mul({{cw.name}}.into())) |
| 56 | + {{/each}} |
| 57 | + {{#if (ne benchmark.base_reads "0")}} |
| 58 | + .saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}})) |
| 59 | + {{/if}} |
| 60 | + {{#each benchmark.component_reads as |cr|}} |
| 61 | + .saturating_add(T::DbWeight::get().reads(({{cr.slope}}_u64).saturating_mul({{cr.name}}.into()))) |
| 62 | + {{/each}} |
| 63 | + {{#if (ne benchmark.base_writes "0")}} |
| 64 | + .saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}})) |
| 65 | + {{/if}} |
| 66 | + {{#each benchmark.component_writes as |cw|}} |
| 67 | + .saturating_add(T::DbWeight::get().writes(({{cw.slope}}_u64).saturating_mul({{cw.name}}.into()))) |
| 68 | + {{/each}} |
| 69 | + } |
| 70 | + {{/each}} |
| 71 | +} |
| 72 | + |
| 73 | +// For backwards compatibility and tests |
| 74 | +impl WeightInfo for () { |
| 75 | + {{#each benchmarks as |benchmark|}} |
| 76 | + {{#each benchmark.comments as |comment|}} |
| 77 | + // {{comment}} |
| 78 | + {{/each}} |
| 79 | + {{#each benchmark.component_ranges as |range|}} |
| 80 | + /// The range of component `{{range.name}}` is `[{{range.min}}, {{range.max}}]`. |
| 81 | + {{/each}} |
| 82 | + fn {{benchmark.name~}} |
| 83 | + ( |
| 84 | + {{~#each benchmark.components as |c| ~}} |
| 85 | + {{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}} |
| 86 | + ) -> Weight { |
| 87 | + // Minimum execution time: {{underscore benchmark.min_execution_time}} nanoseconds. |
| 88 | + Weight::from_ref_time({{underscore benchmark.base_weight}}) |
| 89 | + {{#each benchmark.component_weight as |cw|}} |
| 90 | + // Standard Error: {{underscore cw.error}} |
| 91 | + .saturating_add(Weight::from_ref_time({{underscore cw.slope}}).saturating_mul({{cw.name}}.into())) |
| 92 | + {{/each}} |
| 93 | + {{#if (ne benchmark.base_reads "0")}} |
| 94 | + .saturating_add(RocksDbWeight::get().reads({{benchmark.base_reads}})) |
| 95 | + {{/if}} |
| 96 | + {{#each benchmark.component_reads as |cr|}} |
| 97 | + .saturating_add(RocksDbWeight::get().reads(({{cr.slope}}_u64).saturating_mul({{cr.name}}.into()))) |
| 98 | + {{/each}} |
| 99 | + {{#if (ne benchmark.base_writes "0")}} |
| 100 | + .saturating_add(RocksDbWeight::get().writes({{benchmark.base_writes}})) |
| 101 | + {{/if}} |
| 102 | + {{#each benchmark.component_writes as |cw|}} |
| 103 | + .saturating_add(RocksDbWeight::get().writes(({{cw.slope}}_u64).saturating_mul({{cw.name}}.into()))) |
| 104 | + {{/each}} |
| 105 | + } |
| 106 | + {{/each}} |
| 107 | +} |
0 commit comments