Skip to content

Commit d1601a3

Browse files
author
Stjepan Glavina
committed
Fix CI
1 parent fdfcc5c commit d1601a3

File tree

6 files changed

+59
-59
lines changed

6 files changed

+59
-59
lines changed

async-mutex/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ readme = "../README.md"
1616
event-listener = "2.0.0"
1717

1818
[dev-dependencies]
19+
async-executor = "1.3.0"
1920
async-io = "1.1.2"
20-
async-std = "1.6.2"
2121
futures = "0.3.5"
2222
futures-intrusive = "0.3.1"
2323
futures-lite = "1.0.0"
24+
num_cpus = "1.13.0"
25+
once_cell = "1.4.1"
2426
tokio = { version = "0.2.21", features = ["sync", "parking_lot"] }

async-mutex/benches/async-mutex.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,34 @@
33
extern crate test;
44

55
use std::sync::Arc;
6+
use std::thread;
67

8+
use async_executor::Executor;
79
use async_mutex::Mutex;
8-
use async_std::task;
10+
use futures_lite::future;
11+
use once_cell::sync::Lazy;
912
use test::Bencher;
1013

14+
static EX: Lazy<Executor> = Lazy::new(|| {
15+
for _ in 0..num_cpus::get() {
16+
thread::spawn(|| future::block_on(EX.run(future::pending::<()>())));
17+
}
18+
Executor::new()
19+
});
20+
1121
#[bench]
1222
fn create(b: &mut Bencher) {
1323
b.iter(|| Mutex::new(()));
1424
}
1525

1626
#[bench]
1727
fn contention(b: &mut Bencher) {
18-
b.iter(|| task::block_on(run(10, 1000)));
28+
b.iter(|| future::block_on(run(10, 1000)));
1929
}
2030

2131
#[bench]
2232
fn no_contention(b: &mut Bencher) {
23-
b.iter(|| task::block_on(run(1, 10000)));
33+
b.iter(|| future::block_on(run(1, 10000)));
2434
}
2535

2636
async fn run(task: usize, iter: usize) {
@@ -29,7 +39,7 @@ async fn run(task: usize, iter: usize) {
2939

3040
for _ in 0..task {
3141
let m = m.clone();
32-
tasks.push(task::spawn(async move {
42+
tasks.push(EX.spawn(async move {
3343
for _ in 0..iter {
3444
let _ = m.lock().await;
3545
}

async-mutex/benches/async-std.rs

Lines changed: 0 additions & 42 deletions
This file was deleted.

async-mutex/benches/futures-intrusive.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,34 @@
33
extern crate test;
44

55
use std::sync::Arc;
6+
use std::thread;
67

7-
use async_std::task;
8+
use async_executor::Executor;
89
use futures_intrusive::sync::Mutex;
10+
use futures_lite::future;
11+
use once_cell::sync::Lazy;
912
use test::Bencher;
1013

14+
static EX: Lazy<Executor> = Lazy::new(|| {
15+
for _ in 0..num_cpus::get() {
16+
thread::spawn(|| future::block_on(EX.run(future::pending::<()>())));
17+
}
18+
Executor::new()
19+
});
20+
1121
#[bench]
1222
fn create(b: &mut Bencher) {
1323
b.iter(|| Mutex::new((), true));
1424
}
1525

1626
#[bench]
1727
fn contention(b: &mut Bencher) {
18-
b.iter(|| task::block_on(run(10, 1000)));
28+
b.iter(|| future::block_on(run(10, 1000)));
1929
}
2030

2131
#[bench]
2232
fn no_contention(b: &mut Bencher) {
23-
b.iter(|| task::block_on(run(1, 10000)));
33+
b.iter(|| future::block_on(run(1, 10000)));
2434
}
2535

2636
async fn run(task: usize, iter: usize) {
@@ -29,7 +39,7 @@ async fn run(task: usize, iter: usize) {
2939

3040
for _ in 0..task {
3141
let m = m.clone();
32-
tasks.push(task::spawn(async move {
42+
tasks.push(EX.spawn(async move {
3343
for _ in 0..iter {
3444
let _ = m.lock().await;
3545
}

async-mutex/benches/futures.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,34 @@
33
extern crate test;
44

55
use std::sync::Arc;
6+
use std::thread;
67

7-
use async_std::task;
8+
use async_executor::Executor;
89
use futures::lock::Mutex;
10+
use futures_lite::future;
11+
use once_cell::sync::Lazy;
912
use test::Bencher;
1013

14+
static EX: Lazy<Executor> = Lazy::new(|| {
15+
for _ in 0..num_cpus::get() {
16+
thread::spawn(|| future::block_on(EX.run(future::pending::<()>())));
17+
}
18+
Executor::new()
19+
});
20+
1121
#[bench]
1222
fn create(b: &mut Bencher) {
1323
b.iter(|| Mutex::new(()));
1424
}
1525

1626
#[bench]
1727
fn contention(b: &mut Bencher) {
18-
b.iter(|| task::block_on(run(10, 1000)));
28+
b.iter(|| future::block_on(run(10, 1000)));
1929
}
2030

2131
#[bench]
2232
fn no_contention(b: &mut Bencher) {
23-
b.iter(|| task::block_on(run(1, 10000)));
33+
b.iter(|| future::block_on(run(1, 10000)));
2434
}
2535

2636
async fn run(task: usize, iter: usize) {
@@ -29,7 +39,7 @@ async fn run(task: usize, iter: usize) {
2939

3040
for _ in 0..task {
3141
let m = m.clone();
32-
tasks.push(task::spawn(async move {
42+
tasks.push(EX.spawn(async move {
3343
for _ in 0..iter {
3444
let _ = m.lock().await;
3545
}

async-mutex/benches/tokio.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,34 @@
33
extern crate test;
44

55
use std::sync::Arc;
6+
use std::thread;
67

7-
use async_std::task;
8+
use async_executor::Executor;
9+
use futures_lite::future;
10+
use once_cell::sync::Lazy;
811
use test::Bencher;
912
use tokio::sync::Mutex;
1013

14+
static EX: Lazy<Executor> = Lazy::new(|| {
15+
for _ in 0..num_cpus::get() {
16+
thread::spawn(|| future::block_on(EX.run(future::pending::<()>())));
17+
}
18+
Executor::new()
19+
});
20+
1121
#[bench]
1222
fn create(b: &mut Bencher) {
1323
b.iter(|| Mutex::new(()));
1424
}
1525

1626
#[bench]
1727
fn contention(b: &mut Bencher) {
18-
b.iter(|| task::block_on(run(10, 1000)));
28+
b.iter(|| future::block_on(run(10, 1000)));
1929
}
2030

2131
#[bench]
2232
fn no_contention(b: &mut Bencher) {
23-
b.iter(|| task::block_on(run(1, 10000)));
33+
b.iter(|| future::block_on(run(1, 10000)));
2434
}
2535

2636
async fn run(task: usize, iter: usize) {
@@ -29,7 +39,7 @@ async fn run(task: usize, iter: usize) {
2939

3040
for _ in 0..task {
3141
let m = m.clone();
32-
tasks.push(task::spawn(async move {
42+
tasks.push(EX.spawn(async move {
3343
for _ in 0..iter {
3444
let _ = m.lock().await;
3545
}

0 commit comments

Comments
 (0)