Skip to content

Commit

Permalink
feat(torus0): add benchmarks (#55)
Browse files Browse the repository at this point in the history
Adds the final benchmarks for torus0.
  • Loading branch information
saiintbrisson authored Jan 4, 2025
1 parent ddcc2b0 commit 4acd853
Show file tree
Hide file tree
Showing 14 changed files with 502 additions and 118 deletions.
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ gen-spec-file env: gen-base-spec

run-benchmarks:
cargo build -r --features runtime-benchmarks
# ./target/release/torus-node benchmark pallet --pallet pallet_torus0 --chain dev --extrinsic "*" --steps 50 --repeat 20 --output pallets/torus0/src/weights.rs --template=./.maintain/frame-weight-template.hbs
./target/release/torus-node benchmark pallet --pallet pallet_torus0 --chain dev --extrinsic "*" --steps 50 --repeat 20 --output pallets/torus0/src/weights.rs --template=./.maintain/frame-weight-template.hbs
./target/release/torus-node benchmark pallet --pallet pallet_governance --chain dev --extrinsic "*" --steps 50 --repeat 20 --output pallets/governance/src/weights.rs --template=./.maintain/frame-weight-template.hbs
./target/release/torus-node benchmark pallet --pallet pallet_emission0 --chain dev --extrinsic "*" --steps 50 --repeat 20 --output pallets/emission0/src/weights.rs --template=./.maintain/frame-weight-template.hbs

Expand Down
1 change: 1 addition & 0 deletions pallets/emission0/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ std = [
runtime-benchmarks = [
"polkadot-sdk/runtime-benchmarks",
"pallet-torus0-api/runtime-benchmarks",
"pallet-governance-api/runtime-benchmarks",
]
try-runtime = ["polkadot-sdk/try-runtime"]

Expand Down
26 changes: 13 additions & 13 deletions pallets/emission0/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 43.0.0
//! DATE: 2025-01-03, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `MacBook-Pro-de-Joao.local`, CPU: `<UNKNOWN>`
//! HOSTNAME: `Luizs-MacBook-Pro.local`, CPU: `<UNKNOWN>`
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024`
// Executed Command:
Expand Down Expand Up @@ -64,8 +64,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `339`
// Estimated: `7638`
// Minimum execution time: 33_000_000 picoseconds.
Weight::from_parts(34_000_000, 7638)
// Minimum execution time: 24_000_000 picoseconds.
Weight::from_parts(26_000_000, 7638)
.saturating_add(T::DbWeight::get().reads(8_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
Expand All @@ -77,8 +77,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `168`
// Estimated: `7638`
// Minimum execution time: 17_000_000 picoseconds.
Weight::from_parts(18_000_000, 7638)
// Minimum execution time: 12_000_000 picoseconds.
Weight::from_parts(12_000_000, 7638)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
Expand All @@ -88,8 +88,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `199`
// Estimated: `3529`
// Minimum execution time: 10_000_000 picoseconds.
Weight::from_parts(11_000_000, 3529)
// Minimum execution time: 7_000_000 picoseconds.
Weight::from_parts(8_000_000, 3529)
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
Expand All @@ -115,8 +115,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `339`
// Estimated: `7638`
// Minimum execution time: 33_000_000 picoseconds.
Weight::from_parts(34_000_000, 7638)
// Minimum execution time: 24_000_000 picoseconds.
Weight::from_parts(26_000_000, 7638)
.saturating_add(RocksDbWeight::get().reads(8_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
Expand All @@ -128,8 +128,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `168`
// Estimated: `7638`
// Minimum execution time: 17_000_000 picoseconds.
Weight::from_parts(18_000_000, 7638)
// Minimum execution time: 12_000_000 picoseconds.
Weight::from_parts(12_000_000, 7638)
.saturating_add(RocksDbWeight::get().reads(2_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
Expand All @@ -139,8 +139,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `199`
// Estimated: `3529`
// Minimum execution time: 10_000_000 picoseconds.
Weight::from_parts(11_000_000, 3529)
// Minimum execution time: 7_000_000 picoseconds.
Weight::from_parts(8_000_000, 3529)
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
Expand Down
1 change: 1 addition & 0 deletions pallets/governance/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ runtime-benchmarks = [
"pallet-emission0/runtime-benchmarks",

"pallet-torus0-api/runtime-benchmarks",
"pallet-governance-api/runtime-benchmarks",
]
try-runtime = [
"polkadot-sdk/try-runtime",
Expand Down
6 changes: 6 additions & 0 deletions pallets/governance/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,11 @@ pub trait GovernanceApi<AccountId> {

fn ensure_allocator(key: &AccountId) -> DispatchResult;

#[doc(hidden)]
#[cfg(feature = "runtime-benchmarks")]
fn set_allocator(key: &AccountId);

#[doc(hidden)]
#[cfg(feature = "runtime-benchmarks")]
fn set_whitelisted(key: &AccountId);
}
6 changes: 6 additions & 0 deletions pallets/governance/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,13 @@ impl<T: Config> pallet_governance_api::GovernanceApi<T::AccountId> for Pallet<T>
crate::roles::ensure_allocator::<T>(key)
}

#[cfg(feature = "runtime-benchmarks")]
fn set_allocator(key: &T::AccountId) {
crate::Allocators::<T>::insert(key, ());
}

#[cfg(feature = "runtime-benchmarks")]
fn set_whitelisted(key: &T::AccountId) {
crate::Whitelist::<T>::insert(key, ())
}
}
Loading

0 comments on commit 4acd853

Please sign in to comment.