-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
"flow" op code sanity benchmarks (#1433)
#1386 ``` block target estimation/flow/jmp opcode time: [1.9838 ms 1.9917 ms 2.0001 ms] block target estimation/flow/ji opcode time: [1.6020 ms 1.6119 ms 1.6223 ms] block target estimation/flow/jne opcode time: [2.2373 ms 2.2479 ms 2.2589 ms] block target estimation/flow/jnei opcode time: [2.0990 ms 2.1085 ms 2.1176 ms] block target estimation/flow/jnzi opcode time: [1.9626 ms 1.9776 ms 1.9930 ms] block target estimation/flow/jmpb opcode time: [1.5740 ms 1.5819 ms 1.5904 ms] block target estimation/flow/jmpf opcode time: [1.5385 ms 1.5455 ms 1.5529 ms] block target estimation/flow/jnzb opcode true time: [1.6174 ms 1.6246 ms 1.6323 ms] block target estimation/flow/jnzb opcode false time: [1.6395 ms 1.6482 ms 1.6568 ms] block target estimation/flow/jnzf opcode true time: [1.5932 ms 1.5999 ms 1.6070 ms] block target estimation/flow/jnzf opcode false time: [1.6132 ms 1.6227 ms 1.6333 ms] block target estimation/flow/jne opcode time: [1.7591 ms 1.7703 ms 1.7822 ms] block target estimation/flow/jnei opcode time: [1.5247 ms 1.5340 ms 1.5447 ms] block target estimation/flow/jneb opcode not equal time: [1.6881 ms 1.6961 ms 1.7057 ms] block target estimation/flow/jneb opcode equal time: [1.7255 ms 1.7362 ms 1.7481 ms] block target estimation/flow/jnef opcode not equal time: [1.8018 ms 1.8132 ms 1.8259 ms] block target estimation/flow/jnef opcode equal time: [1.7644 ms 1.7731 ms 1.7823 ms] ``` Not sure how to test `ret_script` or `ret_contract` with an infinite loop 🤷 --------- Co-authored-by: Green Baneling <XgreenX9999@gmail.com>
- Loading branch information
1 parent
fd9bb60
commit 17093e0
Showing
10 changed files
with
230 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use crate::*; | ||
// use crate::utils::arb_dependent_cost_values; | ||
|
||
pub fn run_contract(_group: &mut BenchmarkGroup<WallTime>) { | ||
// This breaks the benchmarking | ||
// for i in arb_dependent_cost_values() { | ||
// let id = format!("flow/retd_contract opcode {:?}", i); | ||
// run( | ||
// &id, | ||
// group, | ||
// vec![ | ||
// op::movi(0x10, i), | ||
// op::retd(RegId::ONE, 0x10), | ||
// op::jmpb(RegId::ZERO, 0), | ||
// ] | ||
// .to_vec(), | ||
// vec![], | ||
// ); | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
use crate::*; | ||
|
||
// JMP: Jump | ||
// JI: Jump immediate | ||
// JNE: Jump if not equal | ||
// JNEI: Jump if not equal immediate | ||
// JNZI: Jump if not zero immediate | ||
// JMPB: Jump relative backwards | ||
// JMPF: Jump relative forwards | ||
// JNZB: Jump if not zero relative backwards | ||
// JNZF: Jump if not zero relative forwards | ||
// JNEB: Jump if not equal relative backwards | ||
// JNEF: Jump if not equal relative forwards | ||
// RET: Return from context | ||
pub fn run_flow(group: &mut BenchmarkGroup<WallTime>) { | ||
run( | ||
"flow/jmp opcode", | ||
group, | ||
vec![op::movi(0x10, 0), op::jmp(0x10)], | ||
vec![], | ||
); | ||
|
||
run( | ||
"flow/ji opcode", | ||
group, | ||
vec![op::ji(0), op::jmpb(RegId::ZERO, 0)], | ||
vec![], | ||
); | ||
|
||
run( | ||
"flow/jne opcode", | ||
group, | ||
vec![ | ||
op::movi(0x10, 0), | ||
op::jne(RegId::ZERO, RegId::ONE, 0x10), | ||
op::jmpb(RegId::ZERO, 0), | ||
], | ||
vec![], | ||
); | ||
|
||
run( | ||
"flow/jnei opcode", | ||
group, | ||
vec![ | ||
op::jnei(RegId::ZERO, RegId::ONE, 0), | ||
op::jmpb(RegId::ZERO, 0), | ||
], | ||
vec![], | ||
); | ||
|
||
run( | ||
"flow/jnzi opcode", | ||
group, | ||
vec![op::jnzi(RegId::ONE, 0), op::jmpb(RegId::ZERO, 0)], | ||
vec![], | ||
); | ||
|
||
run( | ||
"flow/jmpb opcode", | ||
group, | ||
vec![op::noop(), op::jmpb(RegId::ZERO, 0)], | ||
vec![], | ||
); | ||
|
||
run( | ||
"flow/jmpf opcode", | ||
group, | ||
vec![op::jmpf(RegId::ZERO, 0), op::jmpb(RegId::ZERO, 0)], | ||
vec![], | ||
); | ||
|
||
run( | ||
"flow/jnzb opcode true", | ||
group, | ||
vec![ | ||
op::movi(0x10, 1), | ||
op::noop(), | ||
op::jnzb(0x10, RegId::ZERO, 0), | ||
], | ||
vec![], | ||
); | ||
|
||
run( | ||
"flow/jnzb opcode false", | ||
group, | ||
vec![ | ||
op::movi(0x10, 0), | ||
op::noop(), | ||
op::jnzb(0x10, RegId::ZERO, 0), | ||
op::jmpb(RegId::ZERO, 0), | ||
], | ||
vec![], | ||
); | ||
|
||
run( | ||
"flow/jnzf opcode true", | ||
group, | ||
vec![ | ||
op::movi(0x10, 1), | ||
op::noop(), | ||
op::jnzf(0x10, RegId::ZERO, 1), | ||
op::ret(RegId::ZERO), | ||
op::jmpb(RegId::ZERO, 1), | ||
], | ||
vec![], | ||
); | ||
|
||
run( | ||
"flow/jnzf opcode false", | ||
group, | ||
vec![ | ||
op::movi(0x10, 0), | ||
op::noop(), | ||
op::jnzf(0x10, RegId::ZERO, 1), | ||
op::jmpb(RegId::ZERO, 0), | ||
op::noop(), | ||
], | ||
vec![], | ||
); | ||
|
||
run( | ||
"flow/jneb opcode not equal", | ||
group, | ||
vec![ | ||
op::movi(0x10, 1), | ||
op::movi(0x11, 0), | ||
op::noop(), | ||
op::jneb(0x10, 0x11, RegId::ZERO, 0), | ||
], | ||
vec![], | ||
); | ||
|
||
run( | ||
"flow/jneb opcode equal", | ||
group, | ||
vec![ | ||
op::movi(0x10, 1), | ||
op::movi(0x11, 1), | ||
op::noop(), | ||
op::jneb(0x10, 0x11, RegId::ZERO, 0), | ||
op::jmpb(RegId::ZERO, 0), | ||
], | ||
vec![], | ||
); | ||
|
||
run( | ||
"flow/jnef opcode not equal", | ||
group, | ||
vec![ | ||
op::movi(0x10, 1), | ||
op::movi(0x11, 0), | ||
op::noop(), | ||
op::jnef(0x10, 0x11, RegId::ZERO, 1), | ||
op::ret(RegId::ZERO), | ||
op::jmpb(RegId::ZERO, 1), | ||
], | ||
vec![], | ||
); | ||
|
||
run( | ||
"flow/jnef opcode equal", | ||
group, | ||
vec![ | ||
op::movi(0x10, 1), | ||
op::movi(0x11, 1), | ||
op::noop(), | ||
op::jnef(0x10, 0x11, RegId::ZERO, 1), | ||
op::jmpb(RegId::ZERO, 0), | ||
op::noop(), | ||
], | ||
vec![], | ||
); | ||
|
||
// Don't know how to test "returning" op codes | ||
// run( | ||
// "flow/ret_script opcode", | ||
// group, | ||
// vec![op::ret(RegId::ONE), op::jmpb(RegId::ZERO, 0)].to_vec(), | ||
// vec![], | ||
// ); | ||
// | ||
// run( | ||
// "flow/ret_contract opcode", | ||
// group, | ||
// vec![op::ret(RegId::ONE), op::jmpb(RegId::ZERO, 0)].to_vec(), | ||
// vec![], | ||
// ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
pub mod alu; | ||
|
||
pub mod crypto; | ||
|
||
pub mod flow; | ||
|
||
pub mod contract; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters