Skip to content

Commit

Permalink
improve parallel benchmark speed
Browse files Browse the repository at this point in the history
See tokio-rs/tokio#2401

Signed-off-by: 20k-ultra <[email protected]>
  • Loading branch information
20k-ultra committed Feb 27, 2023
1 parent 4939065 commit e9a86a3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions profiler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ pub async fn benchmark(domain: &str, concurrency: usize) -> Result<Vec<Benchmark
let domain_copy = domain.clone();
tasks.push(handle.spawn(async move { run_benchmark(domain_copy).await }));
}
let results = futures::future::join_all(tasks).await;
results.into_iter().map(Result::unwrap).collect()
let mut results = Vec::new();
for handle in tasks {
results.push(handle.await?.unwrap());
}
Ok(results)
}

async fn run_benchmark(domain: Arc<String>) -> Result<Benchmark, io::Error> {
Expand Down

0 comments on commit e9a86a3

Please sign in to comment.