Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Fix instr_br_* benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
athei committed Sep 7, 2021
1 parent 63ef115 commit 5cedbf0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions frame/contracts/src/benchmarking/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1506,7 +1506,7 @@ benchmarks! {
sbox.invoke();
}

// w_br = w_bench - 2 * w_param
// w_br = w_bench - 5 * w_param
instr_br {
let r in 0 .. INSTR_BENCHMARK_BATCHES;
let mut sbox = Sandbox::from(&WasmModule::<T>::from(ModuleDefinition {
Expand All @@ -1531,9 +1531,9 @@ benchmarks! {
sbox.invoke();
}

// w_br_if = w_bench - 5 * w_param
// The two additional pushes + drop are only executed 50% of the time.
// Making it: 3 * w_param + (50% * 4 * w_param)
// w_br_if = w_bench - 8 * w_param
// The additional pushe + drop is only executed 50% of the time.
// Making it: 6 * w_param + (50% * 4 * w_param)
instr_br_if {
let r in 0 .. INSTR_BENCHMARK_BATCHES;
let mut sbox = Sandbox::from(&WasmModule::<T>::from(ModuleDefinition {
Expand All @@ -1559,8 +1559,8 @@ benchmarks! {
sbox.invoke();
}

// w_br_table = w_bench - 3 * w_param
// 1 * w_param + 0.5 * 2 * w_param + 0.25 * 4 * w_param
// w_br_table = w_bench - 6 * w_param
// 4 * w_param + 0.5 * 2 * w_param + 0.25 * 4 * w_param + 0.25 * 0 * w_param
instr_br_table {
let r in 0 .. INSTR_BENCHMARK_BATCHES;
let table = Box::new(BrTableData {
Expand Down
6 changes: 3 additions & 3 deletions frame/contracts/src/schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,9 @@ impl<T: Config> Default for InstructionWeights<T> {
i64store: cost_instr!(instr_i64store, 2),
select: cost_instr!(instr_select, 4),
r#if: cost_instr!(instr_if, 3),
br: cost_instr!(instr_br, 2),
br_if: cost_instr!(instr_br_if, 5),
br_table: cost_instr!(instr_br_table, 3),
br: cost_instr!(instr_br, 5),
br_if: cost_instr!(instr_br_if, 8),
br_table: cost_instr!(instr_br_table, 6),
br_table_per_entry: cost_instr!(instr_br_table_per_entry, 0),
call: cost_instr!(instr_call, 2),
call_indirect: cost_instr!(instr_call_indirect, 3),
Expand Down

0 comments on commit 5cedbf0

Please sign in to comment.