Skip to content

Commit

Permalink
new-benches-3
Browse files Browse the repository at this point in the history
  • Loading branch information
lrazovic authored and JuaniRios committed May 22, 2024
1 parent b5090b4 commit 1502b85
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 209 deletions.
1 change: 0 additions & 1 deletion pallets/funding/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2053,7 +2053,6 @@ mod benchmarks {

let accepted_bids =
vec![smaller_than_wap_accepted_bid, higher_than_wap_accepted_bids].into_iter().flatten().collect_vec();
dbg!(accepted_bids.len());
let rejected_bids = (0..z)
.map(|i| {
BidParams::<T>::new(
Expand Down
4 changes: 2 additions & 2 deletions pallets/funding/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,11 +411,11 @@ impl Config for TestRuntime {
type FundingCurrency = ForeignAssets;
type InvestorOrigin = EnsureInvestor<TestRuntime>;
type ManualAcceptanceDuration = ManualAcceptanceDuration;
type MaxBidsPerProject = ConstU32<1024>;
type MaxBidsPerProject = ConstU32<512>;
type MaxBidsPerUser = ConstU32<25>;
type MaxCapacityThresholds = MaxCapacityThresholds;
type MaxContributionsPerUser = ConstU32<25>;
type MaxEvaluationsPerProject = ConstU32<1024>;
type MaxEvaluationsPerProject = ConstU32<512>;
type MaxEvaluationsPerUser = ConstU32<4>;
type MaxMessageSizeThresholds = MaxMessageSizeThresholds;
type MaxProjectsToUpdateInsertionAttempts = ConstU32<100>;
Expand Down
46 changes: 0 additions & 46 deletions pallets/funding/src/tests/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,50 +635,4 @@ mod async_tests {
let total_bids_count = inst.execute(|| Bids::<TestRuntime>::iter_values().collect_vec().len());
assert_eq!(total_bids_count, max_bids_per_project as usize);
}

#[test]
fn weights() {
// use crate::weights::WeightInfoTest;

for i in 0..0 {
println!("hello");
}
// let max_project_to_update_insertion_attempts: u32 =
// <TestRuntime as Config>::MaxProjectsToUpdateInsertionAttempts::get();
// let max_bids_per_project: u32 = <TestRuntime as Config>::MaxBidsPerProject::get();
// let old_community_max = weights::SubstrateWeight::<TestRuntime>::start_community_funding(
// max_project_to_update_insertion_attempts - 1,
// max_bids_per_project / 2,
// max_bids_per_project / 2,
// )
// .max(WeightInfoOf::<TestRuntime>::start_community_funding(
// max_project_to_update_insertion_attempts - 1,
// max_bids_per_project,
// 0u32,
// ))
// .max(WeightInfoOf::<TestRuntime>::start_community_funding(
// max_project_to_update_insertion_attempts - 1,
// 0u32,
// max_bids_per_project,
// ));
// dbg!(old_community_max);
//
// let new_community_max = weights::SubstrateWeightTest::<TestRuntime>::start_community_funding(
// max_project_to_update_insertion_attempts - 1,
// max_bids_per_project,
// );
// dbg!(new_community_max);
//
// let new_auction_end_max = weights::SubstrateWeightTest::<TestRuntime>::end_auction_closing(
// max_project_to_update_insertion_attempts - 1,
// max_bids_per_project,
// 0,
// );
//
// dbg!(new_auction_end_max);
//
//
// let new_sum = new_community_max + new_auction_end_max;
// dbg!(new_sum);
}
}
156 changes: 0 additions & 156 deletions pallets/funding/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1444,160 +1444,4 @@ impl WeightInfo for () {
.saturating_add(RocksDbWeight::get().reads(2_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
}

pub trait TestWeightInfo {
fn end_auction_closing(x: u32, y: u32, z: u32, ) -> Weight;
fn start_community_funding(x: u32, y: u32, ) -> Weight;
}

/// Weights for `pallet_funding` using the Substrate node and recommended hardware.
pub struct TestSubstrateWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> TestWeightInfo for TestSubstrateWeight<T> {
/// Storage: `Funding::ProjectsDetails` (r:1 w:1)
/// Proof: `Funding::ProjectsDetails` (`max_values`: None, `max_size`: Some(397), added: 2872, mode: `MaxEncodedLen`)
/// Storage: `Funding::ProjectsMetadata` (r:1 w:0)
/// Proof: `Funding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(502), added: 2977, mode: `MaxEncodedLen`)
/// Storage: `Funding::Nonce` (r:1 w:1)
/// Proof: `Funding::Nonce` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
/// Storage: `Random::RandomMaterial` (r:1 w:0)
/// Proof: `Random::RandomMaterial` (`max_values`: Some(1), `max_size`: Some(2594), added: 3089, mode: `MaxEncodedLen`)
/// Storage: `Funding::Bids` (r:513 w:512)
/// Proof: `Funding::Bids` (`max_values`: None, `max_size`: Some(306), added: 2781, mode: `MaxEncodedLen`)
/// Storage: `Funding::DidWithWinningBids` (r:512 w:512)
/// Proof: `Funding::DidWithWinningBids` (`max_values`: None, `max_size`: Some(95), added: 2570, mode: `MaxEncodedLen`)
/// Storage: `Funding::ProjectsToUpdate` (r:100 w:1)
/// Proof: `Funding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(26), added: 2501, mode: `MaxEncodedLen`)
/// The range of component `x` is `[1, 99]`.
/// The range of component `y` is `[0, 512]`.
/// The range of component `z` is `[0, 512]`.
fn end_auction_closing(x: u32, y: u32, z: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `1146 + x * (28 ±0) + y * (272 ±0)`
// Estimated: `4079 + x * (2501 ±0) + y * (2781 ±0)`
// Minimum execution time: 308_810_000 picoseconds.
Weight::from_parts(18_800_680, 4079)
// Standard Error: 33_795
.saturating_add(Weight::from_parts(2_190_348, 0).saturating_mul(x.into()))
// Standard Error: 6_461
.saturating_add(Weight::from_parts(11_358_946, 0).saturating_mul(y.into()))
// Standard Error: 6_461
.saturating_add(Weight::from_parts(3_302, 0).saturating_mul(z.into()))
.saturating_add(T::DbWeight::get().reads(6_u64))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into())))
.saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(y.into())))
.saturating_add(T::DbWeight::get().writes(3_u64))
.saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(y.into())))
.saturating_add(Weight::from_parts(0, 2501).saturating_mul(x.into()))
.saturating_add(Weight::from_parts(0, 2781).saturating_mul(y.into()))
}
/// Storage: `Funding::ProjectsDetails` (r:1 w:1)
/// Proof: `Funding::ProjectsDetails` (`max_values`: None, `max_size`: Some(397), added: 2872, mode: `MaxEncodedLen`)
/// Storage: `Funding::ProjectsMetadata` (r:1 w:0)
/// Proof: `Funding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(502), added: 2977, mode: `MaxEncodedLen`)
/// Storage: `Funding::Nonce` (r:1 w:1)
/// Proof: `Funding::Nonce` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
/// Storage: `Random::RandomMaterial` (r:1 w:0)
/// Proof: `Random::RandomMaterial` (`max_values`: Some(1), `max_size`: Some(2594), added: 3089, mode: `MaxEncodedLen`)
/// Storage: `Funding::Bids` (r:1025 w:1024)
/// Proof: `Funding::Bids` (`max_values`: None, `max_size`: Some(306), added: 2781, mode: `MaxEncodedLen`)
/// Storage: `Oracle::Values` (r:1 w:0)
/// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`)
/// Storage: `Funding::ProjectsToUpdate` (r:100 w:1)
/// Proof: `Funding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(26), added: 2501, mode: `MaxEncodedLen`)
/// The range of component `x` is `[1, 99]`.
/// The range of component `y` is `[0, 1024]`.
fn start_community_funding(x: u32, y: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `1417 + x * (28 ±0) + y * (272 ±0)`
// Estimated: `4079 + x * (2501 ±0) + y * (2781 ±0)`
// Minimum execution time: 296_110_000 picoseconds.
Weight::from_parts(16_431_395, 4079)
// Standard Error: 34_714
.saturating_add(Weight::from_parts(2_547_873, 0).saturating_mul(x.into()))
// Standard Error: 3_320
.saturating_add(Weight::from_parts(8_045_382, 0).saturating_mul(y.into()))
.saturating_add(T::DbWeight::get().reads(7_u64))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into())))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(y.into())))
.saturating_add(T::DbWeight::get().writes(3_u64))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(y.into())))
.saturating_add(Weight::from_parts(0, 2501).saturating_mul(x.into()))
.saturating_add(Weight::from_parts(0, 2781).saturating_mul(y.into()))
}
}

// For backwards compatibility and tests.
impl TestWeightInfo for () {
/// Storage: `Funding::ProjectsDetails` (r:1 w:1)
/// Proof: `Funding::ProjectsDetails` (`max_values`: None, `max_size`: Some(397), added: 2872, mode: `MaxEncodedLen`)
/// Storage: `Funding::ProjectsMetadata` (r:1 w:0)
/// Proof: `Funding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(502), added: 2977, mode: `MaxEncodedLen`)
/// Storage: `Funding::Nonce` (r:1 w:1)
/// Proof: `Funding::Nonce` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
/// Storage: `Random::RandomMaterial` (r:1 w:0)
/// Proof: `Random::RandomMaterial` (`max_values`: Some(1), `max_size`: Some(2594), added: 3089, mode: `MaxEncodedLen`)
/// Storage: `Funding::Bids` (r:513 w:512)
/// Proof: `Funding::Bids` (`max_values`: None, `max_size`: Some(306), added: 2781, mode: `MaxEncodedLen`)
/// Storage: `Funding::DidWithWinningBids` (r:512 w:512)
/// Proof: `Funding::DidWithWinningBids` (`max_values`: None, `max_size`: Some(95), added: 2570, mode: `MaxEncodedLen`)
/// Storage: `Funding::ProjectsToUpdate` (r:100 w:1)
/// Proof: `Funding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(26), added: 2501, mode: `MaxEncodedLen`)
/// The range of component `x` is `[1, 99]`.
/// The range of component `y` is `[0, 512]`.
/// The range of component `z` is `[0, 512]`.
fn end_auction_closing(x: u32, y: u32, z: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `1146 + x * (28 ±0) + y * (272 ±0)`
// Estimated: `4079 + x * (2501 ±0) + y * (2781 ±0)`
// Minimum execution time: 308_810_000 picoseconds.
Weight::from_parts(18_800_680, 4079)
// Standard Error: 33_795
.saturating_add(Weight::from_parts(2_190_348, 0).saturating_mul(x.into()))
// Standard Error: 6_461
.saturating_add(Weight::from_parts(11_358_946, 0).saturating_mul(y.into()))
// Standard Error: 6_461
.saturating_add(Weight::from_parts(3_302, 0).saturating_mul(z.into()))
.saturating_add(RocksDbWeight::get().reads(6_u64))
.saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into())))
.saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(y.into())))
.saturating_add(RocksDbWeight::get().writes(3_u64))
.saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(y.into())))
.saturating_add(Weight::from_parts(0, 2501).saturating_mul(x.into()))
.saturating_add(Weight::from_parts(0, 2781).saturating_mul(y.into()))
}
/// Storage: `Funding::ProjectsDetails` (r:1 w:1)
/// Proof: `Funding::ProjectsDetails` (`max_values`: None, `max_size`: Some(397), added: 2872, mode: `MaxEncodedLen`)
/// Storage: `Funding::ProjectsMetadata` (r:1 w:0)
/// Proof: `Funding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(502), added: 2977, mode: `MaxEncodedLen`)
/// Storage: `Funding::Nonce` (r:1 w:1)
/// Proof: `Funding::Nonce` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
/// Storage: `Random::RandomMaterial` (r:1 w:0)
/// Proof: `Random::RandomMaterial` (`max_values`: Some(1), `max_size`: Some(2594), added: 3089, mode: `MaxEncodedLen`)
/// Storage: `Funding::Bids` (r:1025 w:1024)
/// Proof: `Funding::Bids` (`max_values`: None, `max_size`: Some(306), added: 2781, mode: `MaxEncodedLen`)
/// Storage: `Oracle::Values` (r:1 w:0)
/// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`)
/// Storage: `Funding::ProjectsToUpdate` (r:100 w:1)
/// Proof: `Funding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(26), added: 2501, mode: `MaxEncodedLen`)
/// The range of component `x` is `[1, 99]`.
/// The range of component `y` is `[0, 1024]`.
fn start_community_funding(x: u32, y: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `1417 + x * (28 ±0) + y * (272 ±0)`
// Estimated: `4079 + x * (2501 ±0) + y * (2781 ±0)`
// Minimum execution time: 296_110_000 picoseconds.
Weight::from_parts(16_431_395, 4079)
// Standard Error: 34_714
.saturating_add(Weight::from_parts(2_547_873, 0).saturating_mul(x.into()))
// Standard Error: 3_320
.saturating_add(Weight::from_parts(8_045_382, 0).saturating_mul(y.into()))
.saturating_add(RocksDbWeight::get().reads(7_u64))
.saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into())))
.saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(y.into())))
.saturating_add(RocksDbWeight::get().writes(3_u64))
.saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(y.into())))
.saturating_add(Weight::from_parts(0, 2501).saturating_mul(x.into()))
.saturating_add(Weight::from_parts(0, 2781).saturating_mul(y.into()))
}
}
4 changes: 2 additions & 2 deletions runtimes/polimec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1043,11 +1043,11 @@ impl pallet_funding::Config for Runtime {
type FundingCurrency = ForeignAssets;
type InvestorOrigin = EnsureInvestor<Runtime>;
type ManualAcceptanceDuration = ManualAcceptanceDuration;
type MaxBidsPerProject = ConstU32<1024>;
type MaxBidsPerProject = ConstU32<512>;
type MaxBidsPerUser = ConstU32<16>;
type MaxCapacityThresholds = MaxCapacityThresholds;
type MaxContributionsPerUser = ConstU32<16>;
type MaxEvaluationsPerProject = ConstU32<1024>;
type MaxEvaluationsPerProject = ConstU32<512>;
type MaxEvaluationsPerUser = ConstU32<16>;
type MaxMessageSizeThresholds = MaxMessageSizeThresholds;
type MaxProjectsToUpdateInsertionAttempts = ConstU32<100>;
Expand Down
4 changes: 2 additions & 2 deletions runtimes/politest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,11 +1036,11 @@ impl pallet_funding::Config for Runtime {
type FundingCurrency = ForeignAssets;
type InvestorOrigin = EnsureInvestor<Runtime>;
type ManualAcceptanceDuration = ManualAcceptanceDuration;
type MaxBidsPerProject = ConstU32<1024>;
type MaxBidsPerProject = ConstU32<512>;
type MaxBidsPerUser = ConstU32<16>;
type MaxCapacityThresholds = MaxCapacityThresholds;
type MaxContributionsPerUser = ConstU32<16>;
type MaxEvaluationsPerProject = ConstU32<1024>;
type MaxEvaluationsPerProject = ConstU32<512>;
type MaxEvaluationsPerUser = ConstU32<16>;
type MaxMessageSizeThresholds = MaxMessageSizeThresholds;
type MaxProjectsToUpdateInsertionAttempts = ConstU32<100>;
Expand Down

0 comments on commit 1502b85

Please sign in to comment.