Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
MitchTurner committed Oct 20, 2023
1 parent 3b66c7a commit ed2cc12
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 8 deletions.
59 changes: 58 additions & 1 deletion benches/benches/block_target_gas_set/flow.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
use crate::*;

use rand::{
rngs::StdRng,
SeedableRng,
};

// JMP: Jump
// JI: Jump immediate
// JNE: Jump if not equal
Expand All @@ -13,6 +18,7 @@ use crate::*;
// JNEF: Jump if not equal relative forwards
// RET: Return from context
pub fn run_flow(group: &mut BenchmarkGroup<WallTime>) {
let rng = &mut StdRng::seed_from_u64(2322u64);
// let rng = &mut StdRng::seed_from_u64(2322u64);
//
// let mut linear = vec![1, 10, 100, 1000, 10_000];
Expand Down Expand Up @@ -118,9 +124,60 @@ pub fn run_flow(group: &mut BenchmarkGroup<WallTime>) {
// }
// logd.finish();
run(
"flow/jmp",
"flow/jmp opcode",
group,
vec![op::movi(0x10, 0), op::jmp(0x10)].to_vec(),
vec![],
);

run(
"flow/ji opcode",
group,
vec![op::ji(0), op::jmpb(RegId::ZERO, 0)].to_vec(),
vec![],
);

run(
"flow/jne opcode",
group,
vec![
op::movi(0x10, 0),
op::jne(RegId::ZERO, RegId::ONE, 0x10),
op::jmpb(RegId::ZERO, 0),
]
.to_vec(),
vec![],
);

run(
"flow/jnei opcode",
group,
vec![
op::jnei(RegId::ZERO, RegId::ONE, 0),
op::jmpb(RegId::ZERO, 0),
]
.to_vec(),
vec![],
);

run(
"flow/jnzi opcode",
group,
vec![op::jnzi(RegId::ONE, 0), op::jmpb(RegId::ZERO, 0)].to_vec(),
vec![],
);

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![],
);
}
9 changes: 2 additions & 7 deletions benches/benches/vm_set/flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::iter::successors;

use super::run_group_ref;

use crate::utils::generate_linear_costs;
use criterion::{
Criterion,
Throughput,
Expand All @@ -16,13 +17,7 @@ use rand::{
pub fn run(c: &mut Criterion) {
let rng = &mut StdRng::seed_from_u64(2322u64);

let mut linear = vec![1, 10, 100, 1000, 10_000];
let mut l = successors(Some(100_000.0f64), |n| Some(n / 1.5))
.take(5)
.map(|f| f as u32)
.collect::<Vec<_>>();
l.sort_unstable();
linear.extend(l);
let linear = generate_linear_costs();

run_group_ref(
&mut c.benchmark_group("jmp"),
Expand Down

0 comments on commit ed2cc12

Please sign in to comment.