Skip to content

Commit

Permalink
Benchmark should not panic on server close
Browse files Browse the repository at this point in the history
  • Loading branch information
caspervonb committed May 17, 2023
1 parent 3c71104 commit 0e17d5b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions async-nats/benches/core_nats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ pub fn publish(c: &mut Criterion) {

pub fn subscribe(c: &mut Criterion) {
let server = nats_server::run_basic_server();

let mut subscribe_amount_group = c.benchmark_group("subscribe amount");
subscribe_amount_group.sample_size(30);
subscribe_amount_group.warm_up_time(std::time::Duration::from_secs(1));
Expand All @@ -82,9 +81,12 @@ pub fn subscribe(c: &mut Criterion) {
let msg = &bmsg[0..*size].to_vec();

loop {
nc.publish("bench".to_string(), msg.clone().into())
.await
.unwrap();
let result =
nc.publish("bench".to_string(), msg.clone().into()).await;

if result.is_err() {
break;
}
}
}
});
Expand Down

0 comments on commit 0e17d5b

Please sign in to comment.