revme/cmd/bench/
analysis.rs1use std::time::Instant;
2
3use database::{BenchmarkDB, BENCH_CALLER, BENCH_TARGET};
4use revm::{
5 bytecode::Bytecode,
6 primitives::{bytes, hex, Bytes, TxKind},
7 Context, ExecuteEvm, MainBuilder, MainContext,
8};
9
10const BYTES: &str = include_str!("analysis.hex");
11
12pub fn run() {
13 let bytecode = Bytecode::new_raw(Bytes::from(hex::decode(BYTES).unwrap()));
14
15 let context = Context::mainnet()
17 .with_db(BenchmarkDB::new_bytecode(bytecode))
18 .modify_tx_chained(|tx| {
19 tx.caller = BENCH_CALLER;
21 tx.kind = TxKind::Call(BENCH_TARGET);
22 tx.data = bytes!("8035F0CE");
23 });
24
25 let mut evm = context.build_mainnet();
26
27 let time = Instant::now();
28 let _ = evm.transact_previous();
29 println!("First init: {:?}", time.elapsed());
30
31 let time = Instant::now();
32 let _ = evm.transact_previous();
33 println!("Run: {:?}", time.elapsed());
34}