Skip to content

Commit

Permalink
Optimize oneshot case
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Jan 23, 2022
1 parent 85d0bdc commit 77e70ae
Show file tree
Hide file tree
Showing 5 changed files with 529 additions and 24 deletions.
33 changes: 33 additions & 0 deletions crossbeam-channel/benches/oneshot.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#![feature(test)]

extern crate crossbeam_channel as channel;
extern crate test;

use std::sync::mpsc;

#[bench]
fn oneshot_mpsc(b: &mut test::Bencher) {
b.iter(|| {
let (s, r) = mpsc::channel();
s.send(0).unwrap();
r.recv().unwrap();
});
}

#[bench]
fn oneshot_crossbeam_bounded(b: &mut test::Bencher) {
b.iter(|| {
let (s, r) = channel::bounded(1);
s.send(0).unwrap();
r.recv().unwrap();
});
}

#[bench]
fn oneshot_crossbeam_unbounded(b: &mut test::Bencher) {
b.iter(|| {
let (s, r) = channel::unbounded();
s.send(0).unwrap();
r.recv().unwrap();
});
}
Loading

0 comments on commit 77e70ae

Please sign in to comment.