@@ -66,6 +66,12 @@ fn read_compio_in_tokio(b: &mut Bencher, (path, offsets): &(&Path, &[u64])) {
6666 . iter_custom ( |iter| read_compio_impl ( iter, path, offsets) )
6767}
6868
69+ fn read_compio_in_futures ( b : & mut Bencher , ( path, offsets) : & ( & Path , & [ u64 ] ) ) {
70+ let runtime = CompioInFutures :: default ( ) ;
71+ b. to_async ( & runtime)
72+ . iter_custom ( |iter| read_compio_impl ( iter, path, offsets) )
73+ }
74+
6975fn read_all_tokio ( b : & mut Bencher , ( path, len) : & ( & Path , u64 ) ) {
7076 let runtime = tokio:: runtime:: Builder :: new_current_thread ( )
7177 . enable_all ( )
@@ -116,6 +122,12 @@ fn read_all_compio_in_tokio(b: &mut Bencher, (path, len): &(&Path, u64)) {
116122 . iter_custom ( |iter| read_all_compio_impl ( iter, path, * len) )
117123}
118124
125+ fn read_all_compio_in_futures ( b : & mut Bencher , ( path, len) : & ( & Path , u64 ) ) {
126+ let runtime = CompioInFutures :: default ( ) ;
127+ b. to_async ( & runtime)
128+ . iter_custom ( |iter| read_all_compio_impl ( iter, path, * len) )
129+ }
130+
119131fn read ( c : & mut Criterion ) {
120132 let mut rng = rng ( ) ;
121133
@@ -143,6 +155,11 @@ fn read(c: &mut Criterion) {
143155 & ( & path, & offsets) ,
144156 read_compio_in_tokio,
145157 ) ;
158+ group. bench_with_input :: < _ , _ , ( & Path , & [ u64 ] ) > (
159+ "compio-in-futures" ,
160+ & ( & path, & offsets) ,
161+ read_compio_in_futures,
162+ ) ;
146163
147164 group. finish ( ) ;
148165
@@ -158,6 +175,12 @@ fn read(c: &mut Criterion) {
158175 & ( & path, TOTAL_SIZE ) ,
159176 read_all_compio_in_tokio,
160177 ) ;
178+ group. bench_with_input :: < _ , _ , ( & Path , u64 ) > (
179+ "compio-in-futures" ,
180+ & ( & path, TOTAL_SIZE ) ,
181+ read_all_compio_in_futures,
182+ ) ;
183+
161184 group. finish ( ) ;
162185}
163186
@@ -219,6 +242,13 @@ fn write_compio_in_tokio(b: &mut Bencher, (path, offsets, content): &(&Path, &[u
219242 . iter_custom ( |iter| write_compio_impl ( iter, path, offsets, content. clone ( ) ) )
220243}
221244
245+ fn write_compio_in_futures ( b : & mut Bencher , ( path, offsets, content) : & ( & Path , & [ u64 ] , & [ u8 ] ) ) {
246+ let runtime = CompioInFutures :: default ( ) ;
247+ let content = content. to_vec ( ) ;
248+ b. to_async ( & runtime)
249+ . iter_custom ( |iter| write_compio_impl ( iter, path, offsets, content. clone ( ) ) )
250+ }
251+
222252fn write_all_tokio ( b : & mut Bencher , ( path, content) : & ( & Path , & [ u8 ] ) ) {
223253 let runtime = tokio:: runtime:: Builder :: new_current_thread ( )
224254 . enable_all ( )
@@ -282,6 +312,13 @@ fn write_all_compio_in_tokio(b: &mut Bencher, (path, content): &(&Path, &[u8]))
282312 . iter_custom ( |iter| write_all_compio_impl ( iter, path, content. clone ( ) ) )
283313}
284314
315+ fn write_all_compio_in_futures ( b : & mut Bencher , ( path, content) : & ( & Path , & [ u8 ] ) ) {
316+ let runtime = CompioInFutures :: default ( ) ;
317+ let content = content. to_vec ( ) ;
318+ b. to_async ( & runtime)
319+ . iter_custom ( |iter| write_all_compio_impl ( iter, path, content. clone ( ) ) )
320+ }
321+
285322fn write ( c : & mut Criterion ) {
286323 const WRITE_FILE_SIZE : u64 = 16 ;
287324
@@ -329,6 +366,12 @@ fn write(c: &mut Criterion) {
329366 & ( & path, & offsets, & single_content) ,
330367 write_compio_in_tokio,
331368 ) ;
369+ group. bench_with_input :: < _ , _ , ( & Path , & [ u64 ] , & [ u8 ] ) > (
370+ "compio-in-futures" ,
371+ & ( & path, & offsets, & single_content) ,
372+ write_compio_in_futures,
373+ ) ;
374+
332375 group. finish ( ) ;
333376
334377 let mut group = c. benchmark_group ( "write-all" ) ;
@@ -341,6 +384,11 @@ fn write(c: &mut Criterion) {
341384 & ( & path, & content) ,
342385 write_all_compio_in_tokio,
343386 ) ;
387+ group. bench_with_input :: < _ , _ , ( & Path , & [ u8 ] ) > (
388+ "compio-in-futures" ,
389+ & ( & path, & content) ,
390+ write_all_compio_in_futures,
391+ ) ;
344392
345393 group. finish ( )
346394}
0 commit comments