diff --git a/bench/src/main.rs b/bench/src/main.rs index fc8c9f30..c9c85e06 100644 --- a/bench/src/main.rs +++ b/bench/src/main.rs @@ -12,12 +12,15 @@ use solana_sdk::{ commitment_config::CommitmentConfig, hash::Hash, signature::Keypair, signer::Signer, slot_history::Slot, }; -use std::sync::{atomic::{AtomicU64, Ordering}, Arc}; +use std::sync::{ + atomic::{AtomicU64, Ordering}, + Arc, +}; +use tokio::sync::OnceCell; use tokio::{ sync::{mpsc::UnboundedSender, RwLock}, time::{Duration, Instant}, }; -use tokio::sync::OnceCell; #[tokio::main(flavor = "multi_thread", worker_threads = 16)] async fn main() { @@ -187,11 +190,12 @@ async fn bench( } } } - total_gross_send_time.set(bench_start_time.elapsed()).unwrap(); + total_gross_send_time + .set(bench_start_time.elapsed()) + .unwrap(); }); } // -- main act: send the transactions - let mut metric = Metric::default(); let confirmation_time = Instant::now(); let mut confirmed_count = 0; @@ -233,7 +237,9 @@ async fn bench( metric.add_unsuccessful_transaction(tx.sent_duration); } - metric.set_total_gross_send_time(total_gross_send_time.get().unwrap().as_millis() as f64); + metric.set_total_gross_send_time( + total_gross_send_time.get().unwrap().as_micros() as f64 / 1_000.0, + ); metric.finalize(); metric diff --git a/bench/src/metrics.rs b/bench/src/metrics.rs index 66eb981a..c6405d41 100644 --- a/bench/src/metrics.rs +++ b/bench/src/metrics.rs @@ -48,15 +48,14 @@ impl Metric { } if self.total_gross_send_time_ms > 0.01 { - self.send_tps = - 1000.0 * self.txs_sent as f64 / self.total_gross_send_time_ms; + let total_gross_send_time_secs = self.total_gross_send_time_ms / 1_000.0; + self.send_tps = self.txs_sent as f64 / total_gross_send_time_secs; } if self.txs_confirmed > 0 { self.average_confirmation_time_ms = self.total_confirmation_time.as_millis() as f64 / self.txs_confirmed as f64; } - } pub fn set_total_gross_send_time(&mut self, total_gross_send_time_ms: f64) { @@ -84,6 +83,7 @@ impl AddAssign<&Self> for Metric { self.total_confirmation_time += rhs.total_confirmation_time; self.total_sent_time += rhs.total_sent_time; + self.total_gross_send_time_ms += rhs.total_gross_send_time_ms; self.send_tps += rhs.send_tps; self.finalize(); @@ -104,8 +104,8 @@ impl DivAssign for Metric { Duration::from_micros((self.total_confirmation_time.as_micros() / rhs as u128) as u64); self.total_sent_time = Duration::from_micros((self.total_sent_time.as_micros() / rhs as u128) as u64); - self.send_tps = - self.send_tps / rhs as f64; + self.send_tps = self.send_tps / rhs as f64; + self.total_gross_send_time_ms = self.total_gross_send_time_ms / rhs as f64; self.finalize(); }