revme/cmd/bench/
transfer.rs

1use criterion::Criterion;
2use database::{BenchmarkDB, BENCH_CALLER, BENCH_TARGET};
3use revm::{
4    bytecode::Bytecode,
5    primitives::{TxKind, U256},
6    Context, ExecuteEvm, MainBuilder, MainContext,
7};
8
9pub fn run(criterion: &mut Criterion) {
10    let mut evm = Context::mainnet()
11        .with_db(BenchmarkDB::new_bytecode(Bytecode::new()))
12        .modify_tx_chained(|tx| {
13            // Execution globals block hash/gas_limit/coinbase/timestamp..
14            tx.caller = BENCH_CALLER;
15            tx.kind = TxKind::Call(BENCH_TARGET);
16            tx.value = U256::from(10);
17        })
18        .build_mainnet();
19    criterion.bench_function("transfer", |b| {
20        b.iter(|| {
21            let _ = evm.replay();
22        })
23    });
24}