Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use AtomicU64 instead of u64 for the position field in Receiver #70

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "async-broadcast"
version = "0.7.1"
version = "0.8.0"
license = "MIT OR Apache-2.0"
repository = "https://github.com/smol-rs/async-broadcast"
documentation = "https://docs.rs/async-broadcast"
Expand Down
50 changes: 42 additions & 8 deletions benches/broadcast_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use async_broadcast::broadcast;
use criterion::{criterion_group, criterion_main, Criterion};
use futures_lite::future::block_on;
pub fn broadcast_and_recv(c: &mut Criterion) {
let (s, mut r1) = broadcast(1);
let (s, r1) = broadcast(1);

let mut n = 0;
c.bench_function("1 -> 1", |b| {
Expand All @@ -15,7 +15,7 @@ pub fn broadcast_and_recv(c: &mut Criterion) {
})
});

let mut r2 = r1.clone();
let r2 = r1.clone();

c.bench_function("1 -> 2", |b| {
b.iter(|| {
Expand All @@ -28,8 +28,8 @@ pub fn broadcast_and_recv(c: &mut Criterion) {
})
});

let mut r3 = r1.clone();
let mut r4 = r1.clone();
let r3 = r1.clone();
let r4 = r1.clone();

c.bench_function("1 -> 4", |b| {
b.iter(|| {
Expand All @@ -44,10 +44,10 @@ pub fn broadcast_and_recv(c: &mut Criterion) {
})
});

let mut r5 = r1.clone();
let mut r6 = r1.clone();
let mut r7 = r1.clone();
let mut r8 = r1.clone();
let r5 = r1.clone();
let r6 = r1.clone();
let r7 = r1.clone();
let r8 = r1.clone();

c.bench_function("1 -> 8", |b| {
b.iter(|| {
Expand All @@ -65,6 +65,40 @@ pub fn broadcast_and_recv(c: &mut Criterion) {
})
})
});

let r9 = r1.clone();
let r10 = r1.clone();
let r11 = r1.clone();
let r12 = r1.clone();
let r13 = r1.clone();
let r14 = r1.clone();
let r15 = r1.clone();
let r16 = r1.clone();

c.bench_function("1 -> 16", |b| {
b.iter(|| {
block_on(async {
s.broadcast(n).await.unwrap();
assert_eq!(r1.recv().await.unwrap(), n);
assert_eq!(r2.recv().await.unwrap(), n);
assert_eq!(r3.recv().await.unwrap(), n);
assert_eq!(r4.recv().await.unwrap(), n);
assert_eq!(r5.recv().await.unwrap(), n);
assert_eq!(r6.recv().await.unwrap(), n);
assert_eq!(r7.recv().await.unwrap(), n);
assert_eq!(r8.recv().await.unwrap(), n);
assert_eq!(r9.recv().await.unwrap(), n);
assert_eq!(r10.recv().await.unwrap(), n);
assert_eq!(r11.recv().await.unwrap(), n);
assert_eq!(r12.recv().await.unwrap(), n);
assert_eq!(r13.recv().await.unwrap(), n);
assert_eq!(r14.recv().await.unwrap(), n);
assert_eq!(r15.recv().await.unwrap(), n);
assert_eq!(r16.recv().await.unwrap(), n);
n += 1;
})
})
});
}

criterion_group!(benches, broadcast_and_recv);
Expand Down
Loading
Loading