Skip to content

Commit 12696ed

Browse files
committed
Simple benchmark for ordered lists.
Results: test sending_and_receiving ... bench: 24,264,924 ns/iter (+/- 23,630,790) test sending_and_receiving_ordered ... bench: 60,652,994 ns/iter (+/- 10,448,337) Which means that, while ordered operations are slower than unordered, they're still about twice as fast as the old implementation before crossbeam_channel.
1 parent c39fff4 commit 12696ed

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

benches/benchmarks.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ extern crate pipeliner;
99
use pipeliner::Pipeline;
1010

1111
// This benchmark just tests passing through some data unmodified.
12-
// We're really testing the underlying channel implementation.
13-
// (And: currently, sync::Mutex I've added to simulate spmc. Sorry. :p)
12+
// We're really testing the underlying channel implementation.)
1413
#[bench]
1514
fn sending_and_receiving(b: &mut Bencher) {
1615
let iterations = black_box(10_000);
@@ -22,6 +21,22 @@ fn sending_and_receiving(b: &mut Bencher) {
2221
count += 1;
2322
}
2423

24+
assert_eq!(iterations, count);
25+
println!("Foobar {}", iterations);
26+
});
27+
}
28+
29+
#[bench]
30+
fn sending_and_receiving_ordered(b: &mut Bencher) {
31+
let iterations = black_box(10_000);
32+
let threads = black_box(4);
33+
34+
b.iter(|| {
35+
let mut count = 0;
36+
for _ in (0..iterations).with_threads(threads).ordered_map(|x| x) {
37+
count += 1;
38+
}
39+
2540
assert_eq!(iterations, count);
2641
println!("Foobar {}", iterations);
2742
});

0 commit comments

Comments
 (0)