Debian Codegraph @

benchmarks/benches/pool.rs

raw symbols SCIP
1 use criterion::*;
2
3 fn criterion_benchmark(c: &mut Criterion) {
4 let threads = num_cpus::get().max(1);
5
6 let tasks = 1000;
7
8 let mut group = c.benchmark_group("pool");
9 group.sample_size(10);
10
11 group.bench_function("threadfin", |b| {
12 b.iter_batched(
13 || threadfin::ThreadPool::builder().size(threads).build(),
14 |pool| {
15 for _ in 0..tasks {
16 pool.execute(|| {
17 let _ = black_box(8 + 9);
18 });
19 }
20
21 pool.join();
22 },
23 BatchSize::LargeInput,
24 );
25 });
26
27 group.bench_function("threadpool", |b| {
28 b.iter_batched(
29 || threadpool::ThreadPool::new(threads),
30 |pool| {
31 for _ in 0..tasks {
32 pool.execute(|| {
33 let _ = black_box(8 + 9);
34 });
35 }
36
37 pool.join();
38 },
39 BatchSize::LargeInput,
40 );
41 });
42
43 group.bench_function("rusty_pool", |b| {
44 b.iter_batched(
45 || rusty_pool::ThreadPool::new(threads, threads, std::time::Duration::ZERO),
46 |pool| {
47 for _ in 0..tasks {
48 pool.execute(|| {
49 let _ = black_box(8 + 9);
50 });
51 }
52
53 pool.shutdown_join();
54 },
55 BatchSize::LargeInput,
56 );
57 });
58 }
59
60 criterion_group!(benches, criterion_benchmark);
61 criterion_main!(benches);