use criterion::{criterion_group, criterion_main, Criterion}; use ethers::prelude::*; use hex::FromHex; use subway_rs::relayer; fn bench_construct_bundle(c: &mut Criterion) { // Example Signed Raw Transaction let raw_data: String = "0x02f90312010b845b31f28085037e11d60083061a809400000000009726632680fb29d3f7a9734e3010e280b902a4b0480bbd0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000001111111254fb6c44bac0bed2854e76f90643097d00000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000007efc27e09bddb994000000000000000000000000000000000000000000000000011451bf389ef0cf000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000062d9afa80000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000001be231a5933e022bd0ce375c26e46cb23cb39b387c9c38d904d3fca0082974582e3ece4f17c1ac8bffe8a1a8a22bbf34c35d626acd545199e8ac01793981f89fab00000000000000000000000000000000000000000000000000000000000000c82e95b6c80000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000007de7d621633ec8c5000000000000000000000000000000000000000000000000000000000088b4b40000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000003b6d0340ae461ca67b15dc8dc81ce7615e0320da1a9ab8d5520b7e0f000000000000000000000000000000000000000000000000c080a05fafb325d3aab047a5ff37be215329b967c9f7e09df44583e10d5c9667e76163a07c76bd102451ba27ef1d161b243a9c8f4b1ee88707202038a650aceae0809cc2".to_string(); let prefix_stripped = raw_data.strip_prefix("0x").unwrap_or(raw_data.as_str()); let raw_bytes = Bytes::from(Vec::from_hex(prefix_stripped).unwrap_or_default()); // Benchmark the function c.bench_function("Construct Flashbots Bundle", |b| { b.iter(|| relayer::construct_bundle(vec![raw_bytes.clone()], U64::from(1))) }); } criterion_group! { name = relay; config = Criterion::default(); targets = bench_construct_bundle } criterion_main!(relay);