Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds base benchmark for do_tick in broker pallet #1235

Merged
merged 10 commits into from
Sep 7, 2023
21 changes: 21 additions & 0 deletions substrate/frame/broker/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,27 @@ mod benches {
}
}

#[benchmark]
fn do_tick_base() -> Result<(), BenchmarkError> {
setup_and_start_sale::<T>()?;

advance_to::<T>(5);

let mut status = Status::<T>::get().ok_or(BenchmarkError::Weightless)?;
gupnik marked this conversation as resolved.
Show resolved Hide resolved
status.last_committed_timeslice = 3;
Status::<T>::put(&status);

#[block]
{
Broker::<T>::do_tick();
}

let updated_status = Status::<T>::get().ok_or(BenchmarkError::Weightless)?;
gupnik marked this conversation as resolved.
Show resolved Hide resolved
assert_eq!(status, updated_status);

Ok(())
}

// Implements a test for each benchmark. Execute with:
// `cargo test -p pallet-broker --features runtime-benchmarks`.
impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Test);
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/broker/src/tick_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ impl<T: Config> Pallet<T> {
};

let mut meter = WeightMeter::new();
meter.consume(T::WeightInfo::do_tick_base());
gupnik marked this conversation as resolved.
Show resolved Hide resolved

if Self::process_core_count(&mut status) {
meter.consume(T::WeightInfo::process_core_count(status.core_count.into()));
Expand Down
Loading