From d2be79f38c8cac4fc8a7fe146ab6d53204857c29 Mon Sep 17 00:00:00 2001 From: Greg Fitzgerald Date: Tue, 10 Jul 2018 16:38:47 -0600 Subject: [PATCH] Use iter_with_setup() to improve precision --- benches/bank.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/benches/bank.rs b/benches/bank.rs index d4632977f1..fe67fc6406 100644 --- a/benches/bank.rs +++ b/benches/bank.rs @@ -39,13 +39,17 @@ fn bench_process_transaction(bencher: &mut Bencher) { }) .collect(); - bencher.iter(|| { - // Since benchmarker runs this multiple times, we need to clear the signatures. - bank.clear_signatures(); - - let results = bank.process_transactions(transactions.clone()); - assert!(results.iter().all(Result::is_ok)); - }) + bencher.iter_with_setup( + || { + // Since benchmarker runs this multiple times, we need to clear the signatures. + bank.clear_signatures(); + transactions.clone() + }, + |transactions| { + let results = bank.process_transactions(transactions); + assert!(results.iter().all(Result::is_ok)); + }, + ) } fn bench(criterion: &mut Criterion) {