#![expect(
clippy::significant_drop_tightening,
reason = "Inherent in codspeed criterion_group! macro."
)]
use std::{hint::black_box, time::Instant};
use criterion::{Criterion, criterion_group, criterion_main}; use neqo_transport::{
packet,
recovery::{self, sent},
};
fn sent_packets() -> sent::Packets { letmut pkts = sent::Packets::default(); let now = Instant::now(); // Simulate high bandwidth-delay-product connection. for i in0..2_000u64 {
pkts.track(sent::Packet::new(
packet::Type::Short,
packet::Number::from(i),
now, true,
recovery::Tokens::new(), 100,
));
}
pkts
}
/// Confirm that taking a small number of ranges from the front of /// a large span of sent packets is performant. /// This is the most common pattern when sending at a higher rate. /// New acknowledgments will include low-numbered packets, /// while the acknowledgment rate will ensure that most of the /// outstanding packets remain in flight. fn take_ranges(c: &mut Criterion) {
c.bench_function("sent::Packets::take_ranges", |b| {
b.iter_batched_ref(
sent_packets, // Take the first 90 packets, minus some gaps.
|pkts| black_box(pkts.take_ranges([70..=89, 40..=59, 10..=29])),
criterion::BatchSize::SmallInput,
);
});
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.