revme/cmd/bench/
analysis.rs
1use criterion::Criterion;
2use database::{BenchmarkDB, BENCH_CALLER, BENCH_TARGET};
3use revm::{
4 bytecode::Bytecode,
5 primitives::{bytes, hex, Bytes, TxKind},
6 Context, ExecuteEvm, MainBuilder, MainContext,
7};
8
9const BYTES: &str = include_str!("analysis.hex");
10
11pub fn run(criterion: &mut Criterion) {
12 let bytecode = Bytecode::new_raw(Bytes::from(hex::decode(BYTES).unwrap()));
13 let context = Context::mainnet()
15 .with_db(BenchmarkDB::new_bytecode(bytecode))
16 .modify_tx_chained(|tx| {
17 tx.caller = BENCH_CALLER;
19 tx.kind = TxKind::Call(BENCH_TARGET);
20 tx.data = bytes!("8035F0CE");
21 });
22 let mut evm = context.build_mainnet();
23 criterion.bench_function("analysis", |b| {
24 b.iter(|| {
25 let _ = evm.replay().unwrap();
26 });
27 });
28}