Skip to content

Commit 51b7982

Browse files
committed
"resolved the comments"
1 parent 48024b1 commit 51b7982

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

collector/runtime-benchmarks/async/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "async"
2+
name = "async-bench"
33
version = "0.1.0"
44
edition = "2021"
55

collector/runtime-benchmarks/async/src/main.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
use benchlib::benchmark::run_benchmark_group;
2-
use std::time::Instant;
3-
use tokio::runtime::Runtime;
2+
use tokio::runtime::Builder;
43
use std::fs::File;
5-
use std::io::{self, BufRead, BufReader};
4+
use std::io::{BufRead, BufReader};
65
use flate2::read::GzDecoder;
76

87
async 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

3325
fn 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

Comments
 (0)