From 40a355a42d4a9444dc753c04c6608dade2f06a23 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:13:27 +0200 Subject: Adding upstream version 125.0.1. Signed-off-by: Daniel Baumann --- .../rust/neqo-transport/benches/range_tracker.rs | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 third_party/rust/neqo-transport/benches/range_tracker.rs (limited to 'third_party/rust/neqo-transport/benches/range_tracker.rs') diff --git a/third_party/rust/neqo-transport/benches/range_tracker.rs b/third_party/rust/neqo-transport/benches/range_tracker.rs new file mode 100644 index 0000000000..c2f78f4874 --- /dev/null +++ b/third_party/rust/neqo-transport/benches/range_tracker.rs @@ -0,0 +1,50 @@ +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use criterion::{criterion_group, criterion_main, Criterion}; // black_box +use neqo_transport::send_stream::RangeTracker; + +const CHUNK: u64 = 1000; +const END: u64 = 100_000; +fn build_coalesce(len: u64) -> RangeTracker { + let mut used = RangeTracker::default(); + used.mark_acked(0, CHUNK as usize); + used.mark_sent(CHUNK, END as usize); + // leave a gap or it will coalesce here + for i in 2..=len { + // These do not get immediately coalesced when marking since they're not at the end or start + used.mark_acked(i * CHUNK, CHUNK as usize); + } + used +} + +fn coalesce(c: &mut Criterion, count: u64) { + c.bench_function( + &format!("coalesce_acked_from_zero {count}+1 entries"), + |b| { + b.iter_batched_ref( + || build_coalesce(count), + |used| { + used.mark_acked(CHUNK, CHUNK as usize); + let tail = (count + 1) * CHUNK; + used.mark_sent(tail, CHUNK as usize); + used.mark_acked(tail, CHUNK as usize); + }, + criterion::BatchSize::SmallInput, + ) + }, + ); +} + +fn benchmark_coalesce(c: &mut Criterion) { + coalesce(c, 1); + coalesce(c, 3); + coalesce(c, 10); + coalesce(c, 1000); +} + +criterion_group!(benches, benchmark_coalesce); +criterion_main!(benches); -- cgit v1.2.3