diff --git a/bin/reth-bench/src/bench/new_payload_fcu.rs b/bin/reth-bench/src/bench/new_payload_fcu.rs index 37f8aae01..36b726289 100644 --- a/bin/reth-bench/src/bench/new_payload_fcu.rs +++ b/bin/reth-bench/src/bench/new_payload_fcu.rs @@ -20,7 +20,7 @@ use reth_cli_runner::CliContext; use reth_node_core::args::BenchmarkArgs; use reth_primitives::SealedBlock; use reth_primitives_traits::SealedHeader; -use std::time::Instant; +use std::time::{Duration, Instant}; use tracing::{debug, info}; /// `reth benchmark new-payload-fcu` command @@ -71,8 +71,14 @@ impl Command { // put results in a summary vec so they can be printed at the end let mut results = Vec::new(); let total_benchmark_duration = Instant::now(); + let mut total_wait_time = Duration::ZERO; - while let Some((block, head, safe, finalized)) = receiver.recv().await { + while let Some((block, head, safe, finalized)) = { + let wait_start = Instant::now(); + let result = receiver.recv().await; + total_wait_time += wait_start.elapsed(); + result + } { // just put gas used here let gas_used = block.gas_used; let block_number = block.number; @@ -112,8 +118,9 @@ impl Command { let combined_result = CombinedResult { block_number, new_payload_result, fcu_latency, total_latency }; - // current duration since the start of the benchmark - let current_duration = total_benchmark_duration.elapsed(); + // current duration since the start of the benchmark minus the time + // waiting for blocks + let current_duration = total_benchmark_duration.elapsed() - total_wait_time; // convert gas used to gigagas, then compute gigagas per second info!(%combined_result); diff --git a/bin/reth-bench/src/bench/new_payload_only.rs b/bin/reth-bench/src/bench/new_payload_only.rs index 327829442..877695f97 100644 --- a/bin/reth-bench/src/bench/new_payload_only.rs +++ b/bin/reth-bench/src/bench/new_payload_only.rs @@ -18,7 +18,7 @@ use clap::Parser; use csv::Writer; use reth_cli_runner::CliContext; use reth_node_core::args::BenchmarkArgs; -use std::time::Instant; +use std::time::{Duration, Instant}; use tracing::{debug, info}; /// `reth benchmark new-payload-only` command @@ -56,8 +56,14 @@ impl Command { // put results in a summary vec so they can be printed at the end let mut results = Vec::new(); let total_benchmark_duration = Instant::now(); + let mut total_wait_time = Duration::ZERO; - while let Some(block) = receiver.recv().await { + while let Some(block) = { + let wait_start = Instant::now(); + let result = receiver.recv().await; + total_wait_time += wait_start.elapsed(); + result + } { // just put gas used here let gas_used = block.gas_used; @@ -82,8 +88,9 @@ impl Command { let new_payload_result = NewPayloadResult { gas_used, latency: start.elapsed() }; info!(%new_payload_result); - // current duration since the start of the benchmark - let current_duration = total_benchmark_duration.elapsed(); + // current duration since the start of the benchmark minus the time + // waiting for blocks + let current_duration = total_benchmark_duration.elapsed() - total_wait_time; // record the current result let row = TotalGasRow { block_number, gas_used, time: current_duration };