Skip to content

Commit

Permalink
#1649 Add a microbenchmark for QueryCounter (#1663)
Browse files Browse the repository at this point in the history
  • Loading branch information
justinweng-instaclustr authored Jun 14, 2024
1 parent 42ed20d commit d150aab
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions shotover/benches/benches/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use shotover::transforms::loopback::Loopback;
use shotover::transforms::null::NullSink;
#[cfg(feature = "alpha-transforms")]
use shotover::transforms::protect::{KeyManagerConfig, ProtectConfig};
use shotover::transforms::query_counter::QueryCounter;
use shotover::transforms::redis::cluster_ports_rewrite::RedisClusterPortsRewrite;
use shotover::transforms::throttling::RequestThrottlingConfig;
use shotover::transforms::{
Expand Down Expand Up @@ -295,6 +296,41 @@ fn criterion_benchmark(c: &mut Criterion) {
)
});
}

{
let chain = TransformChainBuilder::new(
vec![
Box::new(QueryCounter::new("chain".to_owned())),
Box::<Loopback>::default(),
],
"bench",
);
let wrapper = Wrapper::new_with_addr(
vec![
Message::from_frame(Frame::Redis(RedisFrame::Array(vec![
RedisFrame::BulkString(Bytes::from_static(b"SET")),
RedisFrame::BulkString(Bytes::from_static(b"foo")),
RedisFrame::BulkString(Bytes::from_static(b"bar")),
]))),
Message::from_frame(Frame::Redis(RedisFrame::Array(vec![
RedisFrame::BulkString(Bytes::from_static(b"GET")),
RedisFrame::BulkString(Bytes::from_static(b"foo")),
]))),
],
"127.0.0.1:6379".parse().unwrap(),
);

group.bench_function("query_counter", |b| {
b.to_async(&rt).iter_batched(
|| BenchInput {
chain: chain.build(TransformContextBuilder::new_test()),
wrapper: wrapper.clone(),
},
BenchInput::bench,
BatchSize::SmallInput,
)
});
}
}

#[cfg(feature = "alpha-transforms")]
Expand Down

0 comments on commit d150aab

Please sign in to comment.