11use benchlib:: benchmark:: run_benchmark_group;
2- use std:: time:: Instant ;
3- use tokio:: runtime:: Runtime ;
2+ use tokio:: runtime:: Builder ;
43use std:: fs:: File ;
5- use std:: io:: { self , BufRead , BufReader } ;
4+ use std:: io:: { BufRead , BufReader } ;
65use flate2:: read:: GzDecoder ;
76
87async fn total_char_count ( reader : BufReader < GzDecoder < File > > , x : & mut usize ) {
@@ -16,18 +15,11 @@ async fn line_char_count(line: String) -> usize {
1615 line_count
1716}
1817
19- async fn async_operation ( ) -> ( usize , u128 ) {
20- let start_time = Instant :: now ( ) ;
21-
22- let file = File :: open ( "./collector/runtime-benchmarks/data/sherlock.txt.gz" ) . expect ( "can't read a file" ) ;
23- let decoder = GzDecoder :: new ( file) ;
24- let reader2 = BufReader :: new ( decoder) ;
18+ async fn async_operation ( ) -> usize {
19+ let reader2 = BufReader :: new ( GzDecoder :: new ( File :: open ( "./collector/runtime-benchmarks/data/sherlock.txt.gz" ) . expect ( "can't read a file" ) ) ) ;
2520 let mut total_char = 0 ;
2621 total_char_count ( reader2, & mut total_char) . await ;
27-
28- let end_time = Instant :: now ( ) ;
29- let duration = end_time - start_time;
30- ( total_char, duration. as_millis ( ) )
22+ total_char
3123}
3224
3325fn main ( ) {
@@ -36,7 +28,11 @@ fn main() {
3628 // This closure should prepare data that will be needed for the benchmark (if any),
3729 // and then return a closure that will actually be benchmarked/profiled.
3830 // Create a Tokio runtime
39- let rt = Runtime :: new ( ) . unwrap ( ) ;
31+ let rt = Builder :: new_multi_thread ( )
32+ . worker_threads ( 1 )
33+ . enable_all ( )
34+ . build ( )
35+ . unwrap ( ) ;
4036 move || {
4137 rt. block_on ( async_operation ( ) ) ;
4238 }
0 commit comments