difftreelog
feat add benchmarks for burn_from
in: master
12 files changed
pallets/common/src/benchmarking.rsdiffbeforeafterboth54 variable_on_chain_schema,54 variable_on_chain_schema,55 const_on_chain_schema,55 const_on_chain_schema,56 meta_update_permission: Default::default(),56 meta_update_permission: Default::default(),57 transfers_enabled: true,58 })57 })59 .and_then(CollectionHandle::try_get)58 .and_then(CollectionHandle::try_get)60 .map(cast)59 .map(cast)pallets/fungible/src/benchmarking.rsdiffbeforeafterboth59 <Pallet<T>>::set_allowance(&collection, &sender, &spender, 200)?;59 <Pallet<T>>::set_allowance(&collection, &sender, &spender, 200)?;60 }: {<Pallet<T>>::transfer_from(&collection, &spender, &sender, &receiver, 100)?}60 }: {<Pallet<T>>::transfer_from(&collection, &spender, &sender, &receiver, 100)?}6162 burn_from {63 bench_init!{64 owner: sub; collection: collection(owner);65 owner: cross_from_sub; sender: cross_sub; burner: cross_sub;66 };67 <Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200))?;68 <Pallet<T>>::set_allowance(&collection, &sender, &burner, 200)?;69 }: {<Pallet<T>>::burn_from(&collection, &burner, &sender, 100)?}61}70}6271pallets/fungible/src/common.rsdiffbeforeafterboth37 }37 }383839 fn burn_from() -> Weight {39 fn burn_from() -> Weight {40 040 <SelfWeightOf<T>>::burn_from()41 }41 }424243 fn set_variable_metadata(_bytes: u32) -> Weight {43 fn set_variable_metadata(_bytes: u32) -> Weight {pallets/fungible/src/weights.rsdiffbeforeafterboth75 .saturating_add(T::DbWeight::get().reads(3 as Weight))75 .saturating_add(T::DbWeight::get().reads(3 as Weight))76 .saturating_add(T::DbWeight::get().writes(3 as Weight))76 .saturating_add(T::DbWeight::get().writes(3 as Weight))77 }77 }78 // Storage: Fungible Allowance (r:1 w:1)79 // Storage: Fungible TotalSupply (r:1 w:1)80 // Storage: Fungible Balance (r:1 w:1)81 fn burn_from() -> Weight {82 (55_874_000 as Weight)83 .saturating_add(T::DbWeight::get().reads(3 as Weight))84 .saturating_add(T::DbWeight::get().writes(3 as Weight))85 }78}86}798780// For backwards compatibility and tests88// For backwards compatibility and tests113 .saturating_add(RocksDbWeight::get().reads(3 as Weight))121 .saturating_add(RocksDbWeight::get().reads(3 as Weight))114 .saturating_add(RocksDbWeight::get().writes(3 as Weight))122 .saturating_add(RocksDbWeight::get().writes(3 as Weight))115 }123 }124 // Storage: Fungible Allowance (r:1 w:1)125 // Storage: Fungible TotalSupply (r:1 w:1)126 // Storage: Fungible Balance (r:1 w:1)127 fn burn_from() -> Weight {128 (55_874_000 as Weight)129 .saturating_add(RocksDbWeight::get().reads(3 as Weight))130 .saturating_add(RocksDbWeight::get().writes(3 as Weight))131 }116}132}117133pallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth89 <Pallet<T>>::set_allowance(&collection, &sender, item, Some(&spender))?;89 <Pallet<T>>::set_allowance(&collection, &sender, item, Some(&spender))?;90 }: {<Pallet<T>>::transfer_from(&collection, &spender, &sender, &receiver, item)?}90 }: {<Pallet<T>>::transfer_from(&collection, &spender, &sender, &receiver, item)?}9192 burn_from {93 bench_init!{94 owner: sub; collection: collection(owner);95 owner: cross_from_sub; sender: cross_sub; burner: cross_sub;96 };97 let item = create_max_item(&collection, &owner, sender.clone())?;98 <Pallet<T>>::set_allowance(&collection, &sender, item, Some(&burner))?;99 }: {<Pallet<T>>::burn_from(&collection, &burner, &sender, item)?}9110092 set_variable_metadata {101 set_variable_metadata {93 let b in 0..CUSTOM_DATA_LIMIT;102 let b in 0..CUSTOM_DATA_LIMIT;pallets/nonfungible/src/common.rsdiffbeforeafterboth38 }38 }393940 fn burn_from() -> Weight {40 fn burn_from() -> Weight {41 041 <SelfWeightOf<T>>::burn_from()42 }42 }434344 fn set_variable_metadata(bytes: u32) -> Weight {44 fn set_variable_metadata(bytes: u32) -> Weight {pallets/nonfungible/src/weights.rsdiffbeforeafterboth98 .saturating_add(T::DbWeight::get().reads(4 as Weight))98 .saturating_add(T::DbWeight::get().reads(4 as Weight))99 .saturating_add(T::DbWeight::get().writes(6 as Weight))99 .saturating_add(T::DbWeight::get().writes(6 as Weight))100 }100 }101 // Storage: Nonfungible Allowance (r:1 w:1)102 // Storage: Nonfungible TokenData (r:1 w:1)103 // Storage: Nonfungible TokensBurnt (r:1 w:1)104 // Storage: Nonfungible Owned (r:0 w:1)105 fn burn_from() -> Weight {106 (53_429_000 as Weight)107 .saturating_add(T::DbWeight::get().reads(3 as Weight))108 .saturating_add(T::DbWeight::get().writes(4 as Weight))109 }101 // Storage: Nonfungible TokenData (r:1 w:1)110 // Storage: Nonfungible TokenData (r:1 w:1)102 fn set_variable_metadata(_b: u32, ) -> Weight {111 fn set_variable_metadata(_b: u32, ) -> Weight {103 (6_380_000 as Weight)112 (6_380_000 as Weight)163 .saturating_add(RocksDbWeight::get().reads(4 as Weight))172 .saturating_add(RocksDbWeight::get().reads(4 as Weight))164 .saturating_add(RocksDbWeight::get().writes(6 as Weight))173 .saturating_add(RocksDbWeight::get().writes(6 as Weight))165 }174 }175 // Storage: Nonfungible Allowance (r:1 w:1)176 // Storage: Nonfungible TokenData (r:1 w:1)177 // Storage: Nonfungible TokensBurnt (r:1 w:1)178 // Storage: Nonfungible Owned (r:0 w:1)179 fn burn_from() -> Weight {180 (53_429_000 as Weight)181 .saturating_add(RocksDbWeight::get().reads(3 as Weight))182 .saturating_add(RocksDbWeight::get().writes(4 as Weight))183 }166 // Storage: Nonfungible TokenData (r:1 w:1)184 // Storage: Nonfungible TokenData (r:1 w:1)167 fn set_variable_metadata(_b: u32, ) -> Weight {185 fn set_variable_metadata(_b: u32, ) -> Weight {168 (6_380_000 as Weight)186 (6_380_000 as Weight)pallets/refungible/src/benchmarking.rsdiffbeforeafterboth149 <Pallet<T>>::set_allowance(&collection, &sender, &spender, item, 200)?;149 <Pallet<T>>::set_allowance(&collection, &sender, &spender, item, 200)?;150 }: {<Pallet<T>>::transfer_from(&collection, &spender, &sender, &receiver, item, 200)?}150 }: {<Pallet<T>>::transfer_from(&collection, &spender, &sender, &receiver, item, 200)?}151152 // Both source account and token is destroyed153 burn_from {154 bench_init!{155 owner: sub; collection: collection(owner);156 owner: cross_from_sub; sender: cross_sub; burner: cross_sub;157 };158 let item = create_max_item(&collection, &owner, [(sender.clone(), 200)])?;159 <Pallet<T>>::set_allowance(&collection, &sender, &burner, item, 200)?;160 }: {<Pallet<T>>::burn_from(&collection, &burner, &sender, item, 200)?}151161152 set_variable_metadata {162 set_variable_metadata {153 let b in 0..CUSTOM_DATA_LIMIT;163 let b in 0..CUSTOM_DATA_LIMIT;pallets/refungible/src/weights.rsdiffbeforeafterboth166 .saturating_add(T::DbWeight::get().reads(5 as Weight))166 .saturating_add(T::DbWeight::get().reads(5 as Weight))167 .saturating_add(T::DbWeight::get().writes(7 as Weight))167 .saturating_add(T::DbWeight::get().writes(7 as Weight))168 }168 }169 // Storage: Refungible Allowance (r:1 w:1)170 // Storage: Refungible TotalSupply (r:1 w:1)171 // Storage: Refungible Balance (r:1 w:1)172 // Storage: Refungible AccountBalance (r:1 w:1)173 // Storage: Refungible TokensBurnt (r:1 w:1)174 // Storage: Refungible TokenData (r:0 w:1)175 // Storage: Refungible Owned (r:0 w:1)176 fn burn_from() -> Weight {177 (60_903_000 as Weight)178 .saturating_add(T::DbWeight::get().reads(5 as Weight))179 .saturating_add(T::DbWeight::get().writes(7 as Weight))180 }169 // Storage: Refungible TokenData (r:1 w:1)181 // Storage: Refungible TokenData (r:1 w:1)170 fn set_variable_metadata(_b: u32, ) -> Weight {182 fn set_variable_metadata(_b: u32, ) -> Weight {171 (6_801_000 as Weight)183 (6_801_000 as Weight)292 .saturating_add(RocksDbWeight::get().reads(5 as Weight))304 .saturating_add(RocksDbWeight::get().reads(5 as Weight))293 .saturating_add(RocksDbWeight::get().writes(7 as Weight))305 .saturating_add(RocksDbWeight::get().writes(7 as Weight))294 }306 }307 // Storage: Refungible Allowance (r:1 w:1)308 // Storage: Refungible TotalSupply (r:1 w:1)309 // Storage: Refungible Balance (r:1 w:1)310 // Storage: Refungible AccountBalance (r:1 w:1)311 // Storage: Refungible TokensBurnt (r:1 w:1)312 // Storage: Refungible TokenData (r:0 w:1)313 // Storage: Refungible Owned (r:0 w:1)314 fn burn_from() -> Weight {315 (60_903_000 as Weight)316 .saturating_add(RocksDbWeight::get().reads(5 as Weight))317 .saturating_add(RocksDbWeight::get().writes(7 as Weight))318 }295 // Storage: Refungible TokenData (r:1 w:1)319 // Storage: Refungible TokenData (r:1 w:1)296 fn set_variable_metadata(_b: u32, ) -> Weight {320 fn set_variable_metadata(_b: u32, ) -> Weight {297 (6_801_000 as Weight)321 (6_801_000 as Weight)pallets/scheduler/src/benchmarking.rsdiffbeforeafterboth33// Add `n` named items to the schedule33// Add `n` named items to the schedule34fn fill_schedule<T: Config>(when: T::BlockNumber, n: u32) -> Result<(), &'static str> {34fn fill_schedule<T: Config>(when: T::BlockNumber, n: u32) -> Result<(), &'static str> {35 // Essentially a no-op call.35 // Essentially a no-op call.36 let call = frame_system::Call::set_storage(vec![]);36 let call = frame_system::Call::set_storage { items: vec![] };37 for i in 0..n {37 for i in 0..n {38 // Named schedule is strictly heavier than anonymous38 // Named schedule is strictly heavier than anonymous39 Scheduler::<T>::do_schedule_named(39 Scheduler::<T>::do_schedule_named(61 let periodic = Some((T::BlockNumber::one(), 100));61 let periodic = Some((T::BlockNumber::one(), 100));62 let priority = 0;62 let priority = 0;63 // Essentially a no-op call.63 // Essentially a no-op call.64 let call = Box::new(frame_system::Call::set_storage(vec![]).into());64 let call = Box::new(frame_system::Call::set_storage { items: vec![] }.into());656566 fill_schedule::<T>(when, s)?;66 fill_schedule::<T>(when, s)?;67 }: _(RawOrigin::Root, when, periodic, priority, call)67 }: _(RawOrigin::Root, when, periodic, priority, call)98 let periodic = Some((T::BlockNumber::one(), 100));98 let periodic = Some((T::BlockNumber::one(), 100));99 let priority = 0;99 let priority = 0;100 // Essentially a no-op call.100 // Essentially a no-op call.101 let call = Box::new(frame_system::Call::set_storage(vec![]).into());101 let call = Box::new(frame_system::Call::set_storage { items: vec![] }.into());102102103 fill_schedule::<T>(when, s)?;103 fill_schedule::<T>(when, s)?;104 }: _(RawOrigin::Root, id, when, periodic, priority, call)104 }: _(RawOrigin::Root, id, when, periodic, priority, call)runtime/Cargo.tomldiffbeforeafterboth23 'frame-support/runtime-benchmarks',23 'frame-support/runtime-benchmarks',24 'frame-system-benchmarking',24 'frame-system-benchmarking',25 'frame-system/runtime-benchmarks',25 'frame-system/runtime-benchmarks',26 'pallet-ethereum/runtime-benchmarks',26 'pallet-evm-migration/runtime-benchmarks',27 'pallet-evm-migration/runtime-benchmarks',28 'pallet-evm-coder-substrate/runtime-benchmarks',27 'pallet-balances/runtime-benchmarks',29 'pallet-balances/runtime-benchmarks',28 'pallet-timestamp/runtime-benchmarks',30 'pallet-timestamp/runtime-benchmarks',29 'pallet-common/runtime-benchmarks',31 'pallet-common/runtime-benchmarks',runtime/src/lib.rsdiffbeforeafterboth1327 list_benchmark!(list, extra, pallet_fungible, Fungible);1327 list_benchmark!(list, extra, pallet_fungible, Fungible);1328 list_benchmark!(list, extra, pallet_refungible, Refungible);1328 list_benchmark!(list, extra, pallet_refungible, Refungible);1329 list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);1329 list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);1330 // list_benchmark!(list, extra, pallet_evm_coder_substrate, EvmCoderSubstrate);133013311331 let storage_info = AllPalletsWithSystem::storage_info();1332 let storage_info = AllPalletsWithSystem::storage_info();133213331360 add_benchmark!(params, batches, pallet_fungible, Fungible);1361 add_benchmark!(params, batches, pallet_fungible, Fungible);1361 add_benchmark!(params, batches, pallet_refungible, Refungible);1362 add_benchmark!(params, batches, pallet_refungible, Refungible);1362 add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);1363 add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);1364 // add_benchmark!(params, batches, pallet_evm_coder_substrate, EvmCoderSubstrate);136313651364 if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }1366 if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }1365 Ok(batches)1367 Ok(batches)