Skip to content

Commit

Permalink
Fix instr benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
athei committed Sep 28, 2024
1 parent 715f53b commit 33023ab
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
12 changes: 7 additions & 5 deletions substrate/frame/revive/fixtures/contracts/instr_benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,22 @@ extern crate common;
use common::input;
use uapi::{HostFn, HostFnImpl as api, ReturnFlags};

static mut MULT: [u32; 5_000] = [1u32; 5_000];

#[no_mangle]
#[polkavm_derive::polkavm_export]
pub extern "C" fn deploy() {}

#[no_mangle]
#[polkavm_derive::polkavm_export]
pub extern "C" fn call() {
input!(rounds: u32, start: u32, div: u32, mult: u32, add: u32, );
input!(rounds: u32, );

let mut acc = start;
let mut acc = 5;

for _ in 0..rounds {
acc = acc / div * mult + add;
for i in 0..rounds {
acc = acc * unsafe { MULT[i as usize] }
}

api::return_value(ReturnFlags::empty(), start.to_le_bytes().as_ref());
api::return_value(ReturnFlags::empty(), acc.to_le_bytes().as_ref());
}
4 changes: 1 addition & 3 deletions substrate/frame/revive/src/benchmarking/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1727,11 +1727,9 @@ mod benchmarks {
// Benchmark the execution of instructions.
#[benchmark(pov_mode = Ignored)]
fn instr(r: Linear<0, INSTR_BENCHMARK_RUNS>) {
// (round, start, div, mult, add)
let input = (r, 1_000u32, 2u32, 3u32, 100u32).encode();
let mut setup = CallSetup::<T>::new(WasmModule::instr());
let (mut ext, module) = setup.ext();
let prepared = CallSetup::<T>::prepare_call(&mut ext, module, input);
let prepared = CallSetup::<T>::prepare_call(&mut ext, module, r.encode());
#[block]
{
prepared.call().unwrap();
Expand Down
8 changes: 4 additions & 4 deletions substrate/frame/revive/src/weights.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 33023ab

Please sign in to comment.