From 4402e1128f043702c483fef1a26985516c1fdb3a Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Sun, 5 Aug 2018 22:41:19 -0700 Subject: [PATCH] Cleanup --- src/bin/bench-tps.rs | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/bin/bench-tps.rs b/src/bin/bench-tps.rs index a6ee445bc6..3e7dcac150 100644 --- a/src/bin/bench-tps.rs +++ b/src/bin/bench-tps.rs @@ -171,30 +171,33 @@ fn generate_txs( shared_txs: &Arc>>>, id: &KeyPair, keypairs: &[KeyPair], - txs: i64, + tx_count: i64, last_id: &Hash, threads: usize, reclaim: bool, ) { - println!("Signing transactions... {} (reclaim={})", txs / 2, reclaim); + println!( + "Signing transactions... {} (reclaim={})", + tx_count / 2, + reclaim + ); let signing_start = Instant::now(); - let transactions: Vec<_> = if !reclaim { - keypairs - .par_iter() - .map(|keypair| Transaction::new(&id, keypair.pubkey(), 1, *last_id)) - .collect() - } else { - keypairs - .par_iter() - .map(|keypair| Transaction::new(keypair, id.pubkey(), 1, *last_id)) - .collect() - }; + let transactions: Vec<_> = keypairs + .par_iter() + .map(|keypair| { + if !reclaim { + Transaction::new(&id, keypair.pubkey(), 1, *last_id) + } else { + Transaction::new(keypair, id.pubkey(), 1, *last_id) + } + }) + .collect(); let duration = signing_start.elapsed(); let ns = duration.as_secs() * 1_000_000_000 + u64::from(duration.subsec_nanos()); - let bsps = txs as f64 / ns as f64; - let nsps = ns as f64 / txs as f64; + let bsps = (tx_count / 2) as f64 / ns as f64; + let nsps = ns as f64 / (tx_count / 2) as f64; println!( "Done. {:.2} thousand signatures per second, {:.2} us per signature, {} ms total time", bsps * 1_000_000_f64,