Skip to content

Commit

Permalink
Replace num_cpus crate with std::thread (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshuawuyts authored May 5, 2023
1 parent 8562c41 commit 85c20eb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ async-channel = "1.4.1"
async-io = "1.1.9"
criterion = { version = "0.4.0", default-features = false, features = ["cargo_bench_support"] }
easy-parallel = "3.1.0"
num_cpus = "1.13.0"
once_cell = "1.16.0"

[[bench]]
Expand Down
7 changes: 6 additions & 1 deletion benches/executor.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::future::Future;
use std::thread::available_parallelism;

use async_executor::Executor;
use criterion::{criterion_group, criterion_main, Criterion};
Expand All @@ -11,7 +12,11 @@ const LIGHT_TASKS: usize = 25_000;
static EX: Executor<'_> = Executor::new();

fn run(f: impl FnOnce(), multithread: bool) {
let limit = if multithread { num_cpus::get() } else { 1 };
let limit = if multithread {
available_parallelism().unwrap().get()
} else {
1
};

let (s, r) = async_channel::bounded::<()>(1);
easy_parallel::Parallel::new()
Expand Down

0 comments on commit 85c20eb

Please sign in to comment.