Skip to content

Commit 085bf0e

Browse files
committed
chore(flashblocks): benchmark pending blocks
1 parent 210fab6 commit 085bf0e

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

crates/flashblocks/benches/pending_state.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use base_reth_flashblocks::{
1313
Flashblock, FlashblocksAPI, FlashblocksReceiver, FlashblocksState, Metadata,
1414
};
1515
use base_reth_test_utils::{accounts::TestAccounts, harness::TestHarness, node::LocalNodeProvider};
16-
use criterion::{BatchSize, Criterion, criterion_group, criterion_main};
16+
use criterion::{BatchSize, Criterion, Throughput, criterion_group, criterion_main};
1717
use op_alloy_consensus::OpDepositReceipt;
1818
use reth::{
1919
chainspec::{ChainSpecProvider, EthChainSpec},
@@ -88,7 +88,7 @@ fn pending_state_benches(c: &mut Criterion) {
8888
init_bench_tracing();
8989

9090
let runtime = Runtime::new().expect("tokio runtime should start");
91-
let setup = runtime.block_on(BenchSetup::new(&[5, 25]));
91+
let setup = runtime.block_on(BenchSetup::new(&[5, 25, 100]));
9292
let mut group = c.benchmark_group("pending_state_build");
9393

9494
for (label, flashblocks) in setup.flashblocks {
@@ -97,6 +97,9 @@ fn pending_state_benches(c: &mut Criterion) {
9797
let target_block = setup.target_block;
9898
let flashblocks = flashblocks.clone();
9999
let last_index = flashblocks.last().map(|fb| fb.index).unwrap_or_default();
100+
let tx_count = flashblocks.iter().map(|fb| fb.diff.transactions.len()).sum::<usize>();
101+
102+
group.throughput(Throughput::Elements(tx_count as u64));
100103

101104
group.bench_function(label, |b| {
102105
b.to_async(&runtime).iter_batched(

crates/flashblocks/src/pending_blocks.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ impl PendingBlocksBuilder {
5555
}
5656

5757
#[inline]
58-
pub(crate) fn with_flashblocks(&mut self, flashblocks: Vec<Flashblock>) -> &Self {
58+
pub(crate) fn with_flashblocks(
59+
&mut self,
60+
flashblocks: impl IntoIterator<Item = Flashblock>,
61+
) -> &Self {
5962
self.flashblocks.extend(flashblocks);
6063
self
6164
}

0 commit comments

Comments
 (0)