mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-06 09:08:18 +00:00
Dont use benchmark range on constant functions (#12456)
* dont use benchmark range on constant function * update weights * fix * new weights * Update frame/examples/basic/src/benchmarking.rs Co-authored-by: parity-processbot <>
This commit is contained in:
@@ -34,25 +34,26 @@ use frame_system::RawOrigin;
|
||||
// Details on using the benchmarks macro can be seen at:
|
||||
// https://paritytech.github.io/substrate/master/frame_benchmarking/trait.Benchmarking.html#tymethod.benchmarks
|
||||
benchmarks! {
|
||||
// This will measure the execution time of `set_dummy` for b in [0..1000] range.
|
||||
// This will measure the execution time of `set_dummy`.
|
||||
set_dummy_benchmark {
|
||||
// This is the benchmark setup phase
|
||||
let b in 0 .. 1000;
|
||||
}: set_dummy(RawOrigin::Root, b.into()) // The execution phase is just running `set_dummy` extrinsic call
|
||||
// This is the benchmark setup phase.
|
||||
// `set_dummy` is a constant time function, hence we hard-code some random value here.
|
||||
let value = 1000u32.into();
|
||||
}: set_dummy(RawOrigin::Root, value) // The execution phase is just running `set_dummy` extrinsic call
|
||||
verify {
|
||||
// This is the optional benchmark verification phase, asserting certain states.
|
||||
assert_eq!(Pallet::<T>::dummy(), Some(b.into()))
|
||||
assert_eq!(Pallet::<T>::dummy(), Some(value))
|
||||
}
|
||||
|
||||
// This will measure the execution time of `accumulate_dummy` for b in [0..1000] range.
|
||||
// This will measure the execution time of `accumulate_dummy`.
|
||||
// The benchmark execution phase is shorthanded. When the name of the benchmark case is the same
|
||||
// as the extrinsic call. `_(...)` is used to represent the extrinsic name.
|
||||
// The benchmark verification phase is omitted.
|
||||
accumulate_dummy {
|
||||
let b in 0 .. 1000;
|
||||
let value = 1000u32.into();
|
||||
// The caller account is whitelisted for DB reads/write by the benchmarking macro.
|
||||
let caller: T::AccountId = whitelisted_caller();
|
||||
}: _(RawOrigin::Signed(caller), b.into())
|
||||
}: _(RawOrigin::Signed(caller), value)
|
||||
|
||||
// This will measure the execution time of sorting a vector.
|
||||
sort_vector {
|
||||
|
||||
Reference in New Issue
Block a user