revme/cmd/bench/
transfer.rs

1use database::{BenchmarkDB, BENCH_CALLER, BENCH_TARGET};
2use revm::{
3    bytecode::Bytecode,
4    primitives::{TxKind, U256},
5    Context, ExecuteEvm, MainBuilder, MainContext,
6};
7use std::time::Instant;
8
9pub fn run() {
10    let time = Instant::now();
11    let mut evm = Context::mainnet()
12        .with_db(BenchmarkDB::new_bytecode(Bytecode::new()))
13        .modify_tx_chained(|tx| {
14            // Execution globals block hash/gas_limit/coinbase/timestamp..
15            tx.caller = BENCH_CALLER;
16            tx.kind = TxKind::Call(BENCH_TARGET);
17            tx.value = U256::from(10);
18        })
19        .build_mainnet();
20    println!("Init: {:?}", time.elapsed());
21
22    let time = Instant::now();
23    let _ = evm.transact_previous();
24    println!("First run: {:?}", time.elapsed());
25
26    let time = Instant::now();
27    let _ = evm.transact_previous();
28    println!("Second run: {:?}", time.elapsed());
29}