@@ -35,11 +35,11 @@ mod yatp_future {
3535 use criterion:: * ;
3636 use std:: sync:: atomic:: * ;
3737 use std:: sync:: * ;
38+ use yatp:: task:: future:: TaskCell ;
3839
39- pub fn spawn_many ( b : & mut Bencher < ' _ > , spawn_count : usize ) {
40+ fn spawn_many ( b : & mut Bencher < ' _ > , pool : yatp :: ThreadPool < TaskCell > , spawn_count : usize ) {
4041 let ( tx, rx) = mpsc:: sync_channel ( 1000 ) ;
4142 let rem = Arc :: new ( AtomicUsize :: new ( 0 ) ) ;
42- let pool = yatp:: Builder :: new ( "spawn_many" ) . build_future_pool ( ) ;
4343
4444 b. iter ( || {
4545 rem. store ( spawn_count, Ordering :: Relaxed ) ;
@@ -58,6 +58,16 @@ mod yatp_future {
5858 let _ = rx. recv ( ) . unwrap ( ) ;
5959 } ) ;
6060 }
61+
62+ pub fn spawn_many_single_level ( b : & mut Bencher < ' _ > , spawn_count : usize ) {
63+ let pool = yatp:: Builder :: new ( "spawn_many" ) . build_future_pool ( ) ;
64+ spawn_many ( b, pool, spawn_count)
65+ }
66+
67+ pub fn spawn_many_multilevel ( b : & mut Bencher < ' _ > , spawn_count : usize ) {
68+ let pool = yatp:: Builder :: new ( "spawn_many" ) . build_multilevel_future_pool ( ) ;
69+ spawn_many ( b, pool, spawn_count)
70+ }
6171}
6272
6373mod threadpool {
@@ -153,13 +163,18 @@ mod async_std {
153163
154164pub fn spawn_many ( b : & mut Criterion ) {
155165 let mut group = b. benchmark_group ( "spawn_many" ) ;
156- for i in & [ 1000 , 4000 , 7000 , 10000 ] {
166+ for i in & [ 1024 , 4096 , 8192 , 16384 ] {
157167 group. bench_with_input ( BenchmarkId :: new ( "yatp::future" , i) , i, |b, i| {
158- yatp_future:: spawn_many ( b, * i)
168+ yatp_future:: spawn_many_single_level ( b, * i)
159169 } ) ;
160170 group. bench_with_input ( BenchmarkId :: new ( "yatp::callback" , i) , i, |b, i| {
161171 yatp_callback:: spawn_many ( b, * i)
162172 } ) ;
173+ group. bench_with_input (
174+ BenchmarkId :: new ( "yatp::future::multilevel" , i) ,
175+ i,
176+ |b, i| yatp_future:: spawn_many_multilevel ( b, * i) ,
177+ ) ;
163178 group. bench_with_input ( BenchmarkId :: new ( "threadpool" , i) , i, |b, i| {
164179 threadpool:: spawn_many ( b, * i)
165180 } ) ;
0 commit comments