Skip to content

Commit

Permalink
feat(reth-bench): substract block fetch waiting time from benchmark d…
Browse files Browse the repository at this point in the history
…uration (#14299)
  • Loading branch information
fgimenez authored Feb 18, 2025
1 parent 534b028 commit 3570f6b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
17 changes: 12 additions & 5 deletions bin/reth-bench/src/bench/new_payload_fcu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();

while let Some((block, head, safe, finalized)) = receiver.recv().await {
let mut total_wait_time = Duration::ZERO;

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;
Expand Down Expand Up @@ -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);
Expand Down
17 changes: 12 additions & 5 deletions bin/reth-bench/src/bench/new_payload_only.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();

while let Some(block) = receiver.recv().await {
let mut total_wait_time = Duration::ZERO;

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;

Expand All @@ -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 };
Expand Down

0 comments on commit 3570f6b

Please sign in to comment.