@@ -14,21 +14,9 @@ use tempfile::NamedTempFile;
14
14
use tokio:: io:: { AsyncReadExt , AsyncSeekExt , AsyncWriteExt } ;
15
15
16
16
#[ cfg( target_os = "linux" ) ]
17
- struct MonoioRuntime ( std:: cell:: RefCell < monoio:: Runtime < monoio:: IoUringDriver > > ) ;
18
-
17
+ mod monoio_wrap;
19
18
#[ cfg( target_os = "linux" ) ]
20
- impl criterion:: async_executor:: AsyncExecutor for MonoioRuntime {
21
- fn block_on < T > ( & self , future : impl futures_util:: Future < Output = T > ) -> T {
22
- self . 0 . borrow_mut ( ) . block_on ( future)
23
- }
24
- }
25
-
26
- #[ cfg( target_os = "linux" ) ]
27
- impl criterion:: async_executor:: AsyncExecutor for & MonoioRuntime {
28
- fn block_on < T > ( & self , future : impl futures_util:: Future < Output = T > ) -> T {
29
- self . 0 . borrow_mut ( ) . block_on ( future)
30
- }
31
- }
19
+ use monoio_wrap:: MonoioRuntime ;
32
20
33
21
criterion_group ! ( fs, read, write) ;
34
22
criterion_main ! ( fs) ;
@@ -118,11 +106,7 @@ fn read_compio_join(b: &mut Bencher, (path, offsets): &(&Path, &[u64])) {
118
106
119
107
#[ cfg( target_os = "linux" ) ]
120
108
fn read_monoio ( b : & mut Bencher , ( path, offsets) : & ( & Path , & [ u64 ] ) ) {
121
- let runtime = MonoioRuntime ( std:: cell:: RefCell :: new (
122
- monoio:: RuntimeBuilder :: < monoio:: IoUringDriver > :: new ( )
123
- . build ( )
124
- . unwrap ( ) ,
125
- ) ) ;
109
+ let runtime = MonoioRuntime :: new ( ) ;
126
110
b. to_async ( & runtime) . iter_custom ( |iter| async move {
127
111
let file = monoio:: fs:: File :: open ( path) . await . unwrap ( ) ;
128
112
@@ -197,11 +181,7 @@ fn read_all_compio(b: &mut Bencher, (path, len): &(&Path, u64)) {
197
181
198
182
#[ cfg( target_os = "linux" ) ]
199
183
fn read_all_monoio ( b : & mut Bencher , ( path, len) : & ( & Path , u64 ) ) {
200
- let runtime = MonoioRuntime ( std:: cell:: RefCell :: new (
201
- monoio:: RuntimeBuilder :: < monoio:: IoUringDriver > :: new ( )
202
- . build ( )
203
- . unwrap ( ) ,
204
- ) ) ;
184
+ let runtime = MonoioRuntime :: new ( ) ;
205
185
b. to_async ( & runtime) . iter_custom ( |iter| async move {
206
186
let file = monoio:: fs:: File :: open ( path) . await . unwrap ( ) ;
207
187
let mut buffer = Box :: new ( [ 0u8 ; BUFFER_SIZE ] ) ;
@@ -363,11 +343,7 @@ fn write_compio_join(b: &mut Bencher, (path, offsets, content): &(&Path, &[u64],
363
343
364
344
#[ cfg( target_os = "linux" ) ]
365
345
fn write_monoio ( b : & mut Bencher , ( path, offsets, content) : & ( & Path , & [ u64 ] , & [ u8 ] ) ) {
366
- let runtime = MonoioRuntime ( std:: cell:: RefCell :: new (
367
- monoio:: RuntimeBuilder :: < monoio:: IoUringDriver > :: new ( )
368
- . build ( )
369
- . unwrap ( ) ,
370
- ) ) ;
346
+ let runtime = MonoioRuntime :: new ( ) ;
371
347
let content = content. to_vec ( ) ;
372
348
b. to_async ( & runtime) . iter_custom ( |iter| {
373
349
let mut content = content. clone ( ) ;
@@ -393,11 +369,7 @@ fn write_monoio(b: &mut Bencher, (path, offsets, content): &(&Path, &[u64], &[u8
393
369
394
370
#[ cfg( target_os = "linux" ) ]
395
371
fn write_monoio_join ( b : & mut Bencher , ( path, offsets, content) : & ( & Path , & [ u64 ] , & [ u8 ] ) ) {
396
- let runtime = MonoioRuntime ( std:: cell:: RefCell :: new (
397
- monoio:: RuntimeBuilder :: < monoio:: IoUringDriver > :: new ( )
398
- . build ( )
399
- . unwrap ( ) ,
400
- ) ) ;
372
+ let runtime = MonoioRuntime :: new ( ) ;
401
373
let content = content. to_vec ( ) ;
402
374
b. to_async ( & runtime) . iter_custom ( |iter| {
403
375
let content = content. clone ( ) ;
@@ -505,11 +477,7 @@ fn write_all_compio(b: &mut Bencher, (path, content): &(&Path, &[u8])) {
505
477
506
478
#[ cfg( target_os = "linux" ) ]
507
479
fn write_all_monoio ( b : & mut Bencher , ( path, content) : & ( & Path , & [ u8 ] ) ) {
508
- let runtime = MonoioRuntime ( std:: cell:: RefCell :: new (
509
- monoio:: RuntimeBuilder :: < monoio:: IoUringDriver > :: new ( )
510
- . build ( )
511
- . unwrap ( ) ,
512
- ) ) ;
480
+ let runtime = MonoioRuntime :: new ( ) ;
513
481
let content = content. to_vec ( ) ;
514
482
b. to_async ( & runtime) . iter_custom ( |iter| {
515
483
let mut content = content. clone ( ) ;
0 commit comments