From 8ce3d95519d4cf542a413cca3c1137a902ca9790 Mon Sep 17 00:00:00 2001 From: Anatoly Yakovenko Date: Thu, 20 Jan 2022 18:20:44 -0800 Subject: [PATCH] fixup --- perf/benches/dedup.rs | 71 +++++++++++++++++++++++++++++-------------- 1 file changed, 48 insertions(+), 23 deletions(-) diff --git a/perf/benches/dedup.rs b/perf/benches/dedup.rs index 573152ee305b93..c50b827500c2d8 100644 --- a/perf/benches/dedup.rs +++ b/perf/benches/dedup.rs @@ -1,3 +1,4 @@ +#![allow(clippy::integer_arithmetic)] #![feature(test)] extern crate test; @@ -31,39 +32,63 @@ fn do_bench_dedup_packets(bencher: &mut Bencher, mut batches: Vec) } #[bench] -fn bench_dedup_same(bencher: &mut Bencher) { - let tx = test_tx(); +#[ignore] +fn bench_dedup_same_small_packets(bencher: &mut Bencher) { + let mut rng = rand::thread_rng(); + let small_packet = test_packet_with_size(128, &mut rng); - // generate packet vector - let mut batches = to_packet_batches( - &std::iter::repeat(tx).take(64 * 1024).collect::>(), + let batches = to_packet_batches( + &std::iter::repeat(small_packet) + .take(4096) + .collect::>(), 128, ); - let packet_count = sigverify::count_packets_in_batches(&batches); - let bloom: AtomicBloom<&[u8]> = Bloom::random(1_000_000, 0.0001, 8 << 22).into(); - println!("packet_count {} {}", packet_count, batches.len()); + do_bench_dedup_packets(bencher, batches); +} - // verify packets - bencher.iter(|| { - let _ans = sigverify::dedup_packets(&bloom, &mut batches); - }) +#[bench] +#[ignore] +fn bench_dedup_same_big_packets(bencher: &mut Bencher) { + let mut rng = rand::thread_rng(); + let big_packet = test_packet_with_size(1024, &mut rng); + + let batches = to_packet_batches( + &std::iter::repeat(big_packet).take(4096).collect::>(), + 128, + ); + + do_bench_dedup_packets(bencher, batches); } #[bench] -fn bench_dedup_diff(bencher: &mut Bencher) { - // generate packet vector - let mut batches = - to_packet_batches(&(0..64 * 1024).map(|_| test_tx()).collect::>(), 128); - let packet_count = sigverify::count_packets_in_batches(&batches); - let bloom: AtomicBloom<&[u8]> = Bloom::random(1_000_000, 0.0001, 8 << 22).into(); +#[ignore] +fn bench_dedup_diff_small_packets(bencher: &mut Bencher) { + let mut rng = rand::thread_rng(); - println!("packet_count {} {}", packet_count, batches.len()); + let batches = to_packet_batches( + &(0..4096) + .map(|_| test_packet_with_size(128, &mut rng)) + .collect::>(), + 128, + ); - // verify packets - bencher.iter(|| { - let _ans = sigverify::dedup_packets(&bloom, &mut batches); - }) + do_bench_dedup_packets(bencher, batches); +} + +#[bench] +#[ignore] +fn bench_dedup_diff_big_packets(bencher: &mut Bencher) { + let mut rng = rand::thread_rng(); + + let batches = to_packet_batches( + &(0..4096) + .map(|_| test_packet_with_size(1024, &mut rng)) + .collect::>(), + 128, + ); + + do_bench_dedup_packets(bencher, batches); } #[bench]