Skip to content

Commit

Permalink
Make benchmarks compile without default features
Browse files Browse the repository at this point in the history
  • Loading branch information
faern committed May 8, 2024
1 parent 21cc85c commit 2bc0207
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions benches/benches.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use std::mem;
use std::time::{Duration, Instant};

criterion_group!(benches, bench);
criterion_main!(benches);
Expand Down Expand Up @@ -36,6 +35,7 @@ macro_rules! bench_send_and_recv {
});)*
group.finish();
}
#[cfg(feature = "std")]
{
let mut group = $c.benchmark_group("create_send_and_recv");
$(group.bench_function(stringify!($type), |b| {
Expand All @@ -47,6 +47,7 @@ macro_rules! bench_send_and_recv {
});)*
group.finish();
}
#[cfg(feature = "std")]
{
let mut group = $c.benchmark_group("create_send_and_recv_ref");
$(group.bench_function(stringify!($type), |b| {
Expand All @@ -72,7 +73,9 @@ fn bench(c: &mut Criterion) {
);

bench_try_recv(c);
#[cfg(feature = "std")]
bench_recv_deadline_now(c);
#[cfg(feature = "std")]
bench_recv_timeout_zero(c);
}

Expand All @@ -87,8 +90,9 @@ fn bench_try_recv(c: &mut Criterion) {
});
}

#[cfg(feature = "std")]
fn bench_recv_deadline_now(c: &mut Criterion) {
let now = Instant::now();
let now = std::time::Instant::now();
{
let (_sender, receiver) = oneshot::channel::<u128>();
c.bench_function("recv_deadline_now", |b| {
Expand All @@ -104,8 +108,9 @@ fn bench_recv_deadline_now(c: &mut Criterion) {
}
}

#[cfg(feature = "std")]
fn bench_recv_timeout_zero(c: &mut Criterion) {
let zero = Duration::from_nanos(0);
let zero = std::time::Duration::from_nanos(0);
{
let (_sender, receiver) = oneshot::channel::<u128>();
c.bench_function("recv_timeout_zero", |b| {
Expand Down

0 comments on commit 2bc0207

Please sign in to comment.