Skip to content

Commit

Permalink
add benchmarking weights
Browse files Browse the repository at this point in the history
  • Loading branch information
Roznovjak committed Aug 11, 2023
1 parent c482a3e commit 3a2507f
Show file tree
Hide file tree
Showing 4 changed files with 198 additions and 11 deletions.
103 changes: 93 additions & 10 deletions pallets/bonds/src/weights.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of HydraDX.

// Copyright (C) 2020-2021 Intergalactic, Limited (GIB).
// Copyright (C) 2020-2023 Intergalactic, Limited (GIB).
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -18,23 +18,24 @@
//! Autogenerated weights for pallet_bonds
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-03-17, STEPS: 5, REPEAT: 20, LOW RANGE: [], HIGH RANGE: []
//! DATE: 2023-08-11, STEPS: 10, REPEAT: 30, LOW RANGE: [], HIGH RANGE: []
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024

// Executed Command:
// target/release/hydradx
// benchmark
// pallet
// --chain=dev
// --steps=5
// --repeat=20
// --steps=10
// --repeat=30
// --execution=wasm
// --wasm-execution=compiled
// --heap-pages=4096
// --template=.maintain/pallet-weight-template.hbs
// --pallet=pallet-bonds
// --output=bonds.rs
// --extrinsic=*

#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(clippy::unnecessary_cast)]
Expand All @@ -55,22 +56,104 @@ pub trait WeightInfo {
pub struct HydraWeight<T>(PhantomData<T>);

impl<T: frame_system::Config> WeightInfo for HydraWeight<T> {
// Storage: AssetRegistry Assets (r:1 w:1)
// Proof: AssetRegistry Assets (max_values: None, max_size: Some(87), added: 2562, mode: MaxEncodedLen)
// Storage: Bonds BondIds (r:1 w:1)
// Proof: Bonds BondIds (max_values: None, max_size: Some(32), added: 2507, mode: MaxEncodedLen)
// Storage: Timestamp Now (r:1 w:0)
// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen)
// Storage: AssetRegistry NextAssetId (r:1 w:1)
// Proof: AssetRegistry NextAssetId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
// Storage: System Account (r:3 w:3)
// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
// Storage: Tokens Accounts (r:1 w:1)
// Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen)
// Storage: Tokens TotalIssuance (r:1 w:1)
// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen)
// Storage: MultiTransactionPayment AccountCurrencyMap (r:1 w:0)
// Proof: MultiTransactionPayment AccountCurrencyMap (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen)
// Storage: MultiTransactionPayment AcceptedCurrencies (r:1 w:0)
// Proof: MultiTransactionPayment AcceptedCurrencies (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen)
// Storage: Bonds Bonds (r:0 w:1)
// Proof: Bonds Bonds (max_values: None, max_size: Some(32), added: 2507, mode: MaxEncodedLen)
// Storage: AssetRegistry AssetIds (r:0 w:1)
// Proof: AssetRegistry AssetIds (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen)
fn issue() -> Weight {
Weight::zero()
// Minimum execution time: 154_679 nanoseconds.
Weight::from_ref_time(159_169_000 as u64)
.saturating_add(T::DbWeight::get().reads(11 as u64))
.saturating_add(T::DbWeight::get().writes(10 as u64))
}

// Storage: Bonds Bonds (r:1 w:0)
// Proof: Bonds Bonds (max_values: None, max_size: Some(32), added: 2507, mode: MaxEncodedLen)
// Storage: Timestamp Now (r:1 w:0)
// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen)
// Storage: Tokens Accounts (r:1 w:1)
// Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen)
// Storage: AssetRegistry Assets (r:1 w:0)
// Proof: AssetRegistry Assets (max_values: None, max_size: Some(87), added: 2562, mode: MaxEncodedLen)
// Storage: Tokens TotalIssuance (r:1 w:1)
// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen)
// Storage: System Account (r:2 w:2)
// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
// Storage: MultiTransactionPayment AccountCurrencyMap (r:0 w:1)
// Proof: MultiTransactionPayment AccountCurrencyMap (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen)
fn redeem() -> Weight {
Weight::zero()
// Minimum execution time: 114_799 nanoseconds.
Weight::from_ref_time(116_103_000 as u64)
.saturating_add(T::DbWeight::get().reads(7 as u64))
.saturating_add(T::DbWeight::get().writes(5 as u64))
}
}

// For backwards compatibility and tests
impl WeightInfo for () {
// Storage: AssetRegistry Assets (r:1 w:1)
// Proof: AssetRegistry Assets (max_values: None, max_size: Some(87), added: 2562, mode: MaxEncodedLen)
// Storage: Bonds BondIds (r:1 w:1)
// Proof: Bonds BondIds (max_values: None, max_size: Some(32), added: 2507, mode: MaxEncodedLen)
// Storage: Timestamp Now (r:1 w:0)
// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen)
// Storage: AssetRegistry NextAssetId (r:1 w:1)
// Proof: AssetRegistry NextAssetId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
// Storage: System Account (r:3 w:3)
// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
// Storage: Tokens Accounts (r:1 w:1)
// Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen)
// Storage: Tokens TotalIssuance (r:1 w:1)
// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen)
// Storage: MultiTransactionPayment AccountCurrencyMap (r:1 w:0)
// Proof: MultiTransactionPayment AccountCurrencyMap (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen)
// Storage: MultiTransactionPayment AcceptedCurrencies (r:1 w:0)
// Proof: MultiTransactionPayment AcceptedCurrencies (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen)
// Storage: Bonds Bonds (r:0 w:1)
// Proof: Bonds Bonds (max_values: None, max_size: Some(32), added: 2507, mode: MaxEncodedLen)
// Storage: AssetRegistry AssetIds (r:0 w:1)
// Proof: AssetRegistry AssetIds (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen)
fn issue() -> Weight {
Weight::zero()
// Minimum execution time: 154_679 nanoseconds.
Weight::from_ref_time(159_169_000)
.saturating_add(RocksDbWeight::get().reads(11))
.saturating_add(RocksDbWeight::get().writes(10))
}

// Storage: Bonds Bonds (r:1 w:0)
// Proof: Bonds Bonds (max_values: None, max_size: Some(32), added: 2507, mode: MaxEncodedLen)
// Storage: Timestamp Now (r:1 w:0)
// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen)
// Storage: Tokens Accounts (r:1 w:1)
// Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen)
// Storage: AssetRegistry Assets (r:1 w:0)
// Proof: AssetRegistry Assets (max_values: None, max_size: Some(87), added: 2562, mode: MaxEncodedLen)
// Storage: Tokens TotalIssuance (r:1 w:1)
// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen)
// Storage: System Account (r:2 w:2)
// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
// Storage: MultiTransactionPayment AccountCurrencyMap (r:0 w:1)
// Proof: MultiTransactionPayment AccountCurrencyMap (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen)
fn redeem() -> Weight {
Weight::zero()
// Minimum execution time: 114_799 nanoseconds.
Weight::from_ref_time(116_103_000)
.saturating_add(RocksDbWeight::get().reads(7))
.saturating_add(RocksDbWeight::get().writes(5))
}
}
2 changes: 1 addition & 1 deletion runtime/hydradx/src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ impl pallet_bonds::Config for Runtime {
type AssetTypeWhitelist = AssetTypeWhitelist;
type ProtocolFee = ProtocolFee;
type FeeReceiver = TreasuryAccount;
type WeightInfo = ();
type WeightInfo = weights::bonds::HydraWeight<Runtime>;
}

// Staking
Expand Down
103 changes: 103 additions & 0 deletions runtime/hydradx/src/weights/bonds.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// This file is part of HydraDX.

// Copyright (C) 2020-2023 Intergalactic, Limited (GIB).
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//! Autogenerated weights for pallet_bonds
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-08-11, STEPS: 10, REPEAT: 30, LOW RANGE: [], HIGH RANGE: []
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024

// Executed Command:
// target/release/hydradx
// benchmark
// pallet
// --chain=dev
// --steps=10
// --repeat=30
// --execution=wasm
// --wasm-execution=compiled
// --heap-pages=4096
// --template=.maintain/pallet-weight-template-no-back.hbs
// --pallet=pallet-bonds
// --output=bonds.rs
// --extrinsic=*

#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(clippy::unnecessary_cast)]

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

use pallet_bonds::weights::WeightInfo;

/// Weights for pallet_bonds using the hydraDX node and recommended hardware.
pub struct HydraWeight<T>(PhantomData<T>);

impl<T: frame_system::Config> WeightInfo for HydraWeight<T> {
// Storage: AssetRegistry Assets (r:1 w:1)
// Proof: AssetRegistry Assets (max_values: None, max_size: Some(87), added: 2562, mode: MaxEncodedLen)
// Storage: Bonds BondIds (r:1 w:1)
// Proof: Bonds BondIds (max_values: None, max_size: Some(32), added: 2507, mode: MaxEncodedLen)
// Storage: Timestamp Now (r:1 w:0)
// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen)
// Storage: AssetRegistry NextAssetId (r:1 w:1)
// Proof: AssetRegistry NextAssetId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
// Storage: System Account (r:3 w:3)
// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
// Storage: Tokens Accounts (r:1 w:1)
// Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen)
// Storage: Tokens TotalIssuance (r:1 w:1)
// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen)
// Storage: MultiTransactionPayment AccountCurrencyMap (r:1 w:0)
// Proof: MultiTransactionPayment AccountCurrencyMap (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen)
// Storage: MultiTransactionPayment AcceptedCurrencies (r:1 w:0)
// Proof: MultiTransactionPayment AcceptedCurrencies (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen)
// Storage: Bonds Bonds (r:0 w:1)
// Proof: Bonds Bonds (max_values: None, max_size: Some(32), added: 2507, mode: MaxEncodedLen)
// Storage: AssetRegistry AssetIds (r:0 w:1)
// Proof: AssetRegistry AssetIds (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen)
fn issue() -> Weight {

Check warning on line 77 in runtime/hydradx/src/weights/bonds.rs

View check run for this annotation

Codecov / codecov/patch

runtime/hydradx/src/weights/bonds.rs#L77

Added line #L77 was not covered by tests
// Minimum execution time: 154_679 nanoseconds.
Weight::from_ref_time(159_169_000 as u64)
.saturating_add(T::DbWeight::get().reads(11 as u64))
.saturating_add(T::DbWeight::get().writes(10 as u64))

Check warning on line 81 in runtime/hydradx/src/weights/bonds.rs

View check run for this annotation

Codecov / codecov/patch

runtime/hydradx/src/weights/bonds.rs#L79-L81

Added lines #L79 - L81 were not covered by tests
}
// Storage: Bonds Bonds (r:1 w:0)
// Proof: Bonds Bonds (max_values: None, max_size: Some(32), added: 2507, mode: MaxEncodedLen)
// Storage: Timestamp Now (r:1 w:0)
// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen)
// Storage: Tokens Accounts (r:1 w:1)
// Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen)
// Storage: AssetRegistry Assets (r:1 w:0)
// Proof: AssetRegistry Assets (max_values: None, max_size: Some(87), added: 2562, mode: MaxEncodedLen)
// Storage: Tokens TotalIssuance (r:1 w:1)
// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen)
// Storage: System Account (r:2 w:2)
// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
// Storage: MultiTransactionPayment AccountCurrencyMap (r:0 w:1)
// Proof: MultiTransactionPayment AccountCurrencyMap (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen)
fn redeem() -> Weight {

Check warning on line 97 in runtime/hydradx/src/weights/bonds.rs

View check run for this annotation

Codecov / codecov/patch

runtime/hydradx/src/weights/bonds.rs#L97

Added line #L97 was not covered by tests
// Minimum execution time: 114_799 nanoseconds.
Weight::from_ref_time(116_103_000 as u64)
.saturating_add(T::DbWeight::get().reads(7 as u64))
.saturating_add(T::DbWeight::get().writes(5 as u64))

Check warning on line 101 in runtime/hydradx/src/weights/bonds.rs

View check run for this annotation

Codecov / codecov/patch

runtime/hydradx/src/weights/bonds.rs#L99-L101

Added lines #L99 - L101 were not covered by tests
}
}
1 change: 1 addition & 0 deletions runtime/hydradx/src/weights/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod balances;
pub mod bonds;
pub mod circuit_breaker;
pub mod claims;
pub mod collator_selection;
Expand Down

0 comments on commit 3a2507f

Please sign in to comment.