Skip to content

Commit

Permalink
Fix bench
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake-Shadle committed Nov 26, 2024
1 parent c669e9b commit 9c420da
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
25 changes: 17 additions & 8 deletions benches/token_router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,31 @@ fn token_router(b: Bencher, token_kind: &str) {
use rand::seq::SliceRandom as _;
let tok = tokens.choose(&mut rand).unwrap();

let mut rc = quilkin::filters::ReadContext::new(
cm.clone(),
quilkin::net::EndpointAddress::LOCALHOST,
pool.clone().alloc(),
);
rc.metadata.insert(
let mut metadata = quilkin::net::endpoint::DynamicMetadata::default();
metadata.insert(
quilkin::net::endpoint::metadata::Key::from_static(
quilkin::filters::capture::CAPTURED_BYTES,
),
quilkin::net::endpoint::metadata::Value::Bytes((*tok).clone().into()),
);

rc
(
cm.clone(),
pool.clone().alloc(),
Vec::with_capacity(1),
metadata,
)
})
.counter(divan::counter::BytesCount::new(total_token_size))
.bench_local_values(|mut rc| {
.bench_local_values(|(cm, buffer, mut dest, metadata)| {
let mut rc = quilkin::filters::ReadContext {
endpoints: cm,
destinations: &mut dest,
source: quilkin::net::EndpointAddress::LOCALHOST,
contents: buffer,
metadata,
};

let _ = divan::black_box(filter.sync_read(&mut rc));
})
}
Expand Down
1 change: 0 additions & 1 deletion src/filters/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ use crate::{
};

/// The input arguments to [`Filter::read`].
#[non_exhaustive]
pub struct ReadContext<'ctx> {
/// The upstream endpoints that the packet will be forwarded to.
pub endpoints: Arc<ClusterMap>,
Expand Down

0 comments on commit 9c420da

Please sign in to comment.