Skip to content

Commit

Permalink
feat(udp/bench): support recvmmsg
Browse files Browse the repository at this point in the history
  • Loading branch information
mxinden committed Oct 20, 2024
1 parent 5609a1d commit 8b31a9b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions quinn-udp/benches/throughput.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::{
use criterion::{criterion_group, criterion_main, Criterion};
use tokio::{io::Interest, runtime::Runtime};

use quinn_udp::{RecvMeta, Transmit, UdpSocketState};
use quinn_udp::{RecvMeta, Transmit, UdpSocketState, BATCH_SIZE};

pub fn criterion_benchmark(c: &mut Criterion) {
const TOTAL_BYTES: usize = 10 * 1024 * 1024;
Expand Down Expand Up @@ -37,12 +37,17 @@ pub fn criterion_benchmark(c: &mut Criterion) {
continue;
}

permutations.push((gso_enabled, gro_enabled));
for recvmmsg_enabled in [false, true] {
permutations.push((gso_enabled, gro_enabled, recvmmsg_enabled));
}
}
}

for (gso_enabled, gro_enabled) in permutations {
let mut group = c.benchmark_group(format!("gso_{}_gro_{}", gso_enabled, gro_enabled));
for (gso_enabled, gro_enabled, recvmmsg_enabled) in permutations {
let mut group = c.benchmark_group(format!(
"gso_{}_gro_{}_recvmmsg_{}",
gso_enabled, gro_enabled, recvmmsg_enabled
));
group.throughput(criterion::Throughput::Bytes(TOTAL_BYTES as u64));

let gso_segments = if gso_enabled {
Expand All @@ -63,7 +68,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
} else {
1
};
let batch_size = 1;
let batch_size = if recvmmsg_enabled { BATCH_SIZE } else { 1 };

group.bench_function("throughput", |b| {
b.to_async(Runtime::new().unwrap()).iter(|| async {
Expand Down

0 comments on commit 8b31a9b

Please sign in to comment.