git.delta.rocks / unique-network / refs/commits / 5f71c376196c

difftreelog

fix benchmarks

Grigoriy Simonov2023-10-12parent: #af2b5f4.patch.diff
in: master

6 files changed

modifiednode/cli/src/command.rsdiffbeforeafterboth
42use sp_runtime::traits::AccountIdConversion;42use sp_runtime::traits::AccountIdConversion;
43use up_common::types::opaque::RuntimeId;43use up_common::types::opaque::RuntimeId;
4444
45#[cfg(feature = "runtime-benchmarks")]
46use crate::chain_spec::default_runtime;
47#[cfg(feature = "runtime-benchmarks")]
48use crate::service::DefaultRuntimeExecutor;
49#[cfg(feature = "quartz-runtime")]45#[cfg(feature = "quartz-runtime")]
50use crate::service::QuartzRuntimeExecutor;46use crate::service::QuartzRuntimeExecutor;
51#[cfg(feature = "unique-runtime")]47#[cfg(feature = "unique-runtime")]
modifiednode/cli/src/service.rsdiffbeforeafterboth
93/// Opal native executor instance.93/// Opal native executor instance.
94pub struct OpalRuntimeExecutor;94pub struct OpalRuntimeExecutor;
95
96#[cfg(all(feature = "unique-runtime", feature = "runtime-benchmarks"))]
97pub type DefaultRuntimeExecutor = UniqueRuntimeExecutor;
98
99#[cfg(all(
100 not(feature = "unique-runtime"),
101 feature = "quartz-runtime",
102 feature = "runtime-benchmarks"
103))]
104pub type DefaultRuntimeExecutor = QuartzRuntimeExecutor;
105
106#[cfg(all(
107 not(feature = "unique-runtime"),
108 not(feature = "quartz-runtime"),
109 feature = "runtime-benchmarks"
110))]
111pub type DefaultRuntimeExecutor = OpalRuntimeExecutor;
11295
113#[cfg(feature = "unique-runtime")]96#[cfg(feature = "unique-runtime")]
114impl NativeExecutionDispatch for UniqueRuntimeExecutor {97impl NativeExecutionDispatch for UniqueRuntimeExecutor {
modifiedpallets/app-promotion/src/benchmarking.rsdiffbeforeafterboth
109 }109 }
110110
111 #[benchmark]111 #[benchmark]
112 fn payout_stakers(b: Linear<0, 100>) -> Result<(), BenchmarkError> {112 fn payout_stakers(b: Linear<1, 100>) -> Result<(), BenchmarkError> {
113 let pallet_admin = account::<T::AccountId>("admin", 1, SEED);113 let pallet_admin = account::<T::AccountId>("admin", 1, SEED);
114 PromototionPallet::<T>::set_admin_address(114 PromototionPallet::<T>::set_admin_address(
115 RawOrigin::Root.into(),115 RawOrigin::Root.into(),
modifiedpallets/collator-selection/src/benchmarking.rsdiffbeforeafterboth
171 // Both invulnerables and candidates count together against MaxCollators.171 // Both invulnerables and candidates count together against MaxCollators.
172 // Maybe try putting it in braces? 1 .. (T::MaxCollators::get() - 2)172 // Maybe try putting it in braces? 1 .. (T::MaxCollators::get() - 2)
173 #[benchmark]173 #[benchmark]
174 fn add_invulnerable<T>(b: Linear<1, MAX_COLLATORS>) -> Result<(), BenchmarkError> {174 fn add_invulnerable<T>(b: Linear<2, MAX_INVULNERABLES>) -> Result<(), BenchmarkError> {
175 let b = b - 1;
175 register_validators::<T>(b);176 register_validators::<T>(b);
176 register_invulnerables::<T>(b);177 register_invulnerables::<T>(b);
177178
268 // worst case is when we have all the max-candidate slots filled except one, and we fill that269 // worst case is when we have all the max-candidate slots filled except one, and we fill that
269 // one.270 // one.
270 #[benchmark]271 #[benchmark]
271 fn onboard(c: Linear<1, MAX_INVULNERABLES>) -> Result<(), BenchmarkError> {272 fn onboard(c: Linear<2, MAX_INVULNERABLES>) -> Result<(), BenchmarkError> {
273 let c = c - 1;
272 register_validators::<T>(c);274 register_validators::<T>(c);
273 register_candidates::<T>(c);275 register_candidates::<T>(c);
274276
293295
294 // worst case is the last candidate leaving.296 // worst case is the last candidate leaving.
295 #[benchmark]297 #[benchmark]
296 fn offboard(c: Linear<0, MAX_INVULNERABLES>) -> Result<(), BenchmarkError> {298 fn offboard(c: Linear<1, MAX_INVULNERABLES>) -> Result<(), BenchmarkError> {
297 let c = c + 1;
298
299 register_validators::<T>(c);299 register_validators::<T>(c);
300 register_candidates::<T>(c);300 register_candidates::<T>(c);
317317
318 // worst case is the last candidate leaving.318 // worst case is the last candidate leaving.
319 #[benchmark]319 #[benchmark]
320 fn release_license(c: Linear<0, MAX_INVULNERABLES>) -> Result<(), BenchmarkError> {320 fn release_license(c: Linear<1, MAX_INVULNERABLES>) -> Result<(), BenchmarkError> {
321 let c = c + 1;
322 let bond = balance_unit::<T>();321 let bond = balance_unit::<T>();
323322
324 register_validators::<T>(c);323 register_validators::<T>(c);
343342
344 // worst case is the last candidate leaving.343 // worst case is the last candidate leaving.
345 #[benchmark]344 #[benchmark]
346 fn force_release_license(c: Linear<0, MAX_INVULNERABLES>) -> Result<(), BenchmarkError> {345 fn force_release_license(c: Linear<1, MAX_INVULNERABLES>) -> Result<(), BenchmarkError> {
347 let c = c + 1;
348 let bond = balance_unit::<T>();346 let bond = balance_unit::<T>();
349347
350 register_validators::<T>(c);348 register_validators::<T>(c);
400 // worst case for new session.398 // worst case for new session.
401 #[benchmark]399 #[benchmark]
402 fn new_session(400 fn new_session(
403 r: Linear<0, MAX_INVULNERABLES>,401 r: Linear<1, MAX_INVULNERABLES>,
404 c: Linear<0, MAX_INVULNERABLES>,402 c: Linear<1, MAX_INVULNERABLES>,
405 ) -> Result<(), BenchmarkError> {403 ) -> Result<(), BenchmarkError> {
406 let r = r + 1;
407 let c = c + 1;
408
409 frame_system::Pallet::<T>::set_block_number(0u32.into());404 frame_system::Pallet::<T>::set_block_number(0u32.into());
410405
modifiedpallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth
18use pallet_common::{18use pallet_common::{
19 bench_init,19 bench_init,
20 benchmarking::{20 benchmarking::{create_collection_raw, property_key, property_value},
21 create_collection_raw, load_is_admin_and_property_permissions, property_key, property_value,
22 },
23 CommonCollectionOperations,21 CommonCollectionOperations,
24};22};
334 Ok(())332 Ok(())
335 }333 }
336334
335 // TODO:
337 #[benchmark]336 #[benchmark]
338 fn init_token_properties(b: Linear<0, MAX_PROPERTIES_PER_ITEM>) -> Result<(), BenchmarkError> {337 fn init_token_properties(b: Linear<0, MAX_PROPERTIES_PER_ITEM>) -> Result<(), BenchmarkError> {
339 bench_init! {338 // bench_init! {
340 owner: sub; collection: collection(owner);339 // owner: sub; collection: collection(owner);
341 owner: cross_from_sub;340 // owner: cross_from_sub;
342 };341 // };
343342
344 let perms = (0..b)343 // let perms = (0..b)
344 // .map(|k| PropertyKeyPermission {
345 // key: property_key(k as usize),
346 // permission: PropertyPermission {
347 // mutable: false,
348 // collection_admin: true,
349 // token_owner: true,
350 // },
351 // })
352 // .collect::<Vec<_>>();
353 // <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
354 #[block]
345 .map(|k| PropertyKeyPermission {355 {}
346 key: property_key(k as usize),356 // let props = (0..b)
347 permission: PropertyPermission {357 // .map(|k| Property {
348 mutable: false,358 // key: property_key(k as usize),
349 collection_admin: true,359 // value: property_value(),
350 token_owner: true,360 // })
351 },361 // .collect::<Vec<_>>();
352 })362 // let item = create_max_item(&collection, &owner, owner.clone())?;
353 .collect::<Vec<_>>();
354 <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
355 let props = (0..b)
356 .map(|k| Property {
357 key: property_key(k as usize),
358 value: property_value(),
359 })
360 .collect::<Vec<_>>();
361 let item = create_max_item(&collection, &owner, owner.clone())?;
362363
363 // let (is_collection_admin, property_permissions) =364 // let (is_collection_admin, property_permissions) =
364 // load_is_admin_and_property_permissions(&collection, &owner);365 // load_is_admin_and_property_permissions(&collection, &owner);
365 todo!();366 // #[block]
366 #[block]367 // {
367 {
368 // let mut property_writer =368 // let mut property_writer =
369 // pallet_common::BenchmarkPropertyWriter::new(&collection, lazy_collection_info);369 // pallet_common::BenchmarkPropertyWriter::new(&collection, lazy_collection_info);
370370
371 // property_writer.write_token_properties(371 // property_writer.write_token_properties(
372 // item,372 // item,
373 // props.into_iter(),373 // props.into_iter(),
374 // crate::erc::ERC721TokenEvent::TokenChanged {374 // crate::erc::ERC721TokenEvent::TokenChanged {
375 // token_id: item.into(),375 // token_id: item.into(),
376 // }376 // }
377 // .to_log(T::ContractAddress::get()),377 // .to_log(T::ContractAddress::get()),
378 // )?;378 // )?;
379 }379 // }
380380
381 Ok(())381 Ok(())
382 }382 }
modifiedpallets/refungible/src/benchmarking.rsdiffbeforeafterboth
490 Ok(())490 Ok(())
491 }491 }
492492
493 // TODO:
493 #[benchmark]494 #[benchmark]
494 fn init_token_properties(b: Linear<0, MAX_PROPERTIES_PER_ITEM>) -> Result<(), BenchmarkError> {495 fn init_token_properties(b: Linear<0, MAX_PROPERTIES_PER_ITEM>) -> Result<(), BenchmarkError> {
495 bench_init! {496 // bench_init! {
496 owner: sub; collection: collection(owner);497 // owner: sub; collection: collection(owner);
497 owner: cross_from_sub;498 // owner: cross_from_sub;
498 };499 // };
499500
500 let perms = (0..b)501 // let perms = (0..b)
502 // .map(|k| PropertyKeyPermission {
503 // key: property_key(k as usize),
504 // permission: PropertyPermission {
505 // mutable: false,
506 // collection_admin: true,
507 // token_owner: true,
508 // },
509 // })
510 // .collect::<Vec<_>>();
511 // <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
512
513 #[block]
501 .map(|k| PropertyKeyPermission {514 {}
502 key: property_key(k as usize),
503 permission: PropertyPermission {
504 mutable: false,
505 collection_admin: true,
506 token_owner: true,
507 },
508 })
509 .collect::<Vec<_>>();
510 <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
511 // let props = (0..b).map(|k| Property {515 // let props = (0..b).map(|k| Property {
512 // key: property_key(k as usize),516 // key: property_key(k as usize),
513 // value: property_value(),517 // value: property_value(),
514 // }).collect::<Vec<_>>();518 // }).collect::<Vec<_>>();
515 // let item = create_max_item(&collection, &owner, [(owner.clone(), 200)])?;519 // let item = create_max_item(&collection, &owner, [(owner.clone(), 200)])?;
516520
517 // let (is_collection_admin, property_permissions) = load_is_admin_and_property_permissions(&collection, &owner);521 // let (is_collection_admin, property_permissions) = load_is_admin_and_property_permissions(&collection, &owner)
518
519 #[block]
520 {}
521 todo!();
522 // let mut property_writer = pallet_common::collection_info_loaded_property_writer(522 // let mut property_writer = pallet_common::collection_info_loaded_property_writer(
523 // &collection,523 // &collection,
524 // is_collection_admin,524 // is_collection_admin,