From 07568e88a115ddf16c6be55d1c276b9d77d25039 Mon Sep 17 00:00:00 2001 From: Andrew Fitzgerald Date: Thu, 11 Jan 2024 09:46:59 -0800 Subject: [PATCH] consumer bench same number of txs per iteration --- core/benches/consumer.rs | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/core/benches/consumer.rs b/core/benches/consumer.rs index 735255d59cc160..f056fdd0d49a34 100644 --- a/core/benches/consumer.rs +++ b/core/benches/consumer.rs @@ -139,6 +139,16 @@ fn bench_process_and_record_transactions( batch_size: usize, apply_cost_tracker_during_replay: bool, ) { + const TRANSACTIONS_PER_ITERATION: usize = 64; + assert_eq!( + TRANSACTIONS_PER_ITERATION % batch_size, + 0, + "batch_size must be a factor of \ + `TRANSACTIONS_PER_ITERATION` ({TRANSACTIONS_PER_ITERATION}) \ + so that bench results are easily comparable" + ); + let batches_per_iteration = TRANSACTIONS_PER_ITERATION / batch_size; + let BenchFrame { bank, ledger_path: _ledger_path, @@ -152,12 +162,17 @@ fn bench_process_and_record_transactions( let mut transaction_iter = transactions.chunks(batch_size); bencher.iter(move || { - let summary = - consumer.process_and_record_transactions(&bank, transaction_iter.next().unwrap(), 0); - assert!(summary - .execute_and_commit_transactions_output - .commit_transactions_result - .is_ok()); + for _ in 0..batches_per_iteration { + let summary = consumer.process_and_record_transactions( + &bank, + transaction_iter.next().unwrap(), + 0, + ); + assert!(summary + .execute_and_commit_transactions_output + .commit_transactions_result + .is_ok()); + } }); exit.store(true, Ordering::Relaxed);