1
1
use benchlib:: benchmark:: run_benchmark_group;
2
- use std:: time:: Instant ;
3
- use tokio:: runtime:: Runtime ;
2
+ use tokio:: runtime:: Builder ;
4
3
use std:: fs:: File ;
5
- use std:: io:: { self , BufRead , BufReader } ;
4
+ use std:: io:: { BufRead , BufReader } ;
6
5
use flate2:: read:: GzDecoder ;
7
6
8
7
async fn total_char_count ( reader : BufReader < GzDecoder < File > > , x : & mut usize ) {
@@ -16,18 +15,11 @@ async fn line_char_count(line: String) -> usize {
16
15
line_count
17
16
}
18
17
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" ) ) ) ;
25
20
let mut total_char = 0 ;
26
21
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
31
23
}
32
24
33
25
fn main ( ) {
@@ -36,7 +28,11 @@ fn main() {
36
28
// This closure should prepare data that will be needed for the benchmark (if any),
37
29
// and then return a closure that will actually be benchmarked/profiled.
38
30
// 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 ( ) ;
40
36
move || {
41
37
rt. block_on ( async_operation ( ) ) ;
42
38
}
0 commit comments