-
Notifications
You must be signed in to change notification settings - Fork 154
Fix #1829 #1872
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Daksh-10
wants to merge
7
commits into
rust-lang:master
Choose a base branch
from
Daksh-10:Fix-#1829
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Fix #1829 #1872
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
eb1e963
Added an async runtime benchmark
Daksh-10 3cc2939
changed the way to count characters
Daksh-10 48024b1
resolve the problems
Daksh-10 51b7982
"resolved the comments"
Daksh-10 69d94de
Added Cargo.lock and improved the code
Daksh-10 77900e3
increased size of string
Daksh-10 8868473
I/O operations in memory giving chance to execute asynchronously
Daksh-10 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[package] | ||
name = "async-bench" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
benchlib = { path = "../../benchlib" } | ||
tokio = { version = "1.0", features = ["full"] } | ||
flate2 = "1" | ||
|
||
[workspace] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use benchlib::benchmark::run_benchmark_group; | ||
use tokio::runtime::Builder; | ||
use std::fs::File; | ||
use std::io::{BufRead, BufReader}; | ||
use flate2::read::GzDecoder; | ||
|
||
async fn total_char_count(reader: BufReader<GzDecoder<File>>,x: &mut usize) { | ||
Kobzol marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for line in reader.lines() { | ||
*x += line_char_count(line.expect("invalid character")).await; | ||
} | ||
} | ||
|
||
async fn line_char_count(line: String) -> usize { | ||
let line_count = line.chars().count(); | ||
line_count | ||
} | ||
|
||
async fn async_operation() -> usize { | ||
Kobzol marked this conversation as resolved.
Show resolved
Hide resolved
|
||
let reader2 = BufReader::new(GzDecoder::new(File::open("./collector/runtime-benchmarks/data/sherlock.txt.gz").expect("can't read a file"))); | ||
let mut total_char = 0; | ||
total_char_count(reader2, &mut total_char).await; | ||
total_char | ||
} | ||
|
||
fn main() { | ||
run_benchmark_group(|group| { | ||
group.register_benchmark("Async", || { | ||
// This closure should prepare data that will be needed for the benchmark (if any), | ||
Kobzol marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// and then return a closure that will actually be benchmarked/profiled. | ||
// Create a Tokio runtime | ||
let rt = Builder::new_multi_thread() | ||
Kobzol marked this conversation as resolved.
Show resolved
Hide resolved
|
||
.worker_threads(1) | ||
.enable_all() | ||
.build() | ||
.unwrap(); | ||
move || { | ||
rt.block_on(async_operation()); | ||
Kobzol marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
}); | ||
}); | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.