-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
"flow" op code sanity benchmarks #1433
Changes from all commits
d912246
c7e318f
1f47b1d
de5f327
590bd77
c5cc553
1aa43d7
baf119c
10f4b29
52607e2
3b66c7a
ed2cc12
10fc114
45f895d
f85e595
278d056
c92da04
bebd99a
e874e0b
e84ee99
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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![], | ||
// ); | ||
// } | ||
} |
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![], | ||
// ); | ||
Comment on lines
+174
to
+187
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, You can skip it for now, but create an issue to write a benchmark later that: the scenario either calls another contract and returns with a lot of data or runs a lot of transactions with this opcode. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added it as a subtask to the parent issue, like we did with |
||
} |
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll probably just keep it since we're gonna add it soon anyway.