Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Prev Previous commit
Next Next commit
fix benchmarks
  • Loading branch information
gui1117 committed Jul 13, 2021
commit 6603341dfd4b62c205d602b70e370fa728fe419c
6 changes: 3 additions & 3 deletions frame/lottery/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ fn setup_lottery<T: Config>(repeat: bool) -> Result<(), &'static str> {
let delay = 5u32.into();
// Calls will be maximum length...
let mut calls = vec![
frame_system::Call::<T>::set_code(vec![]).into();
Box::new(frame_system::Call::<T>::set_code(vec![]).into());
T::MaxCalls::get().saturating_sub(1) as usize
];
// Last call will be the match for worst case scenario.
calls.push(frame_system::Call::<T>::remark(vec![]).into());
calls.push(Box::new(frame_system::Call::<T>::remark(vec![]).into()));
let origin = T::ManagerOrigin::successful_origin();
Lottery::<T>::set_calls(origin.clone(), calls)?;
Lottery::<T>::start_lottery(origin, price, length, delay, repeat)?;
Expand Down Expand Up @@ -72,7 +72,7 @@ benchmarks! {

set_calls {
let n in 0 .. T::MaxCalls::get() as u32;
let calls = vec![frame_system::Call::<T>::remark(vec![]).into(); n as usize];
let calls = vec![Box::new(frame_system::Call::<T>::remark(vec![]).into()); n as usize];

let call = Call::<T>::set_calls(calls);
let origin = T::ManagerOrigin::successful_origin();
Expand Down
1 change: 1 addition & 0 deletions frame/utility/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ std = [
]
runtime-benchmarks = [
"frame-benchmarking",
"frame-system/runtime-benchmarks",
"frame-support/runtime-benchmarks",
]
try-runtime = ["frame-support/try-runtime"]
10 changes: 4 additions & 6 deletions frame/utility/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ fn assert_last_event<T: Config>(generic_event: <T as Config>::Event) {
benchmarks! {
batch {
let c in 0 .. 1000;
let mut calls: Vec<<T as Config>::Call> = Vec::new();
let mut calls = Vec::new();
for i in 0 .. c {
let call = frame_system::Call::remark(vec![]).into();
calls.push(call);
calls.push(Box::new(frame_system::Call::remark(vec![]).into()));
}
let caller = whitelisted_caller();
}: _(RawOrigin::Signed(caller), calls)
Expand All @@ -53,10 +52,9 @@ benchmarks! {

batch_all {
let c in 0 .. 1000;
let mut calls: Vec<<T as Config>::Call> = Vec::new();
let mut calls = Vec::new();
for i in 0 .. c {
let call = frame_system::Call::remark(vec![]).into();
calls.push(call);
calls.push(Box::new(frame_system::Call::remark(vec![]).into()));
}
let caller = whitelisted_caller();
}: _(RawOrigin::Signed(caller), calls)
Expand Down