Skip to content

Commit

Permalink
Merge pull request #216 from hatoo/fix-latency-correction
Browse files Browse the repository at this point in the history
Fix `--latency-correction` adds the time of DNS
  • Loading branch information
hatoo authored Feb 19, 2023
2 parents b6cba31 + 385932a commit 8478100
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Unreleased

- Fix `-z` behaviour to cancel workers at the dead line.
- Fix `--latency-correction` adds the time of DNS. #211
- Fix `-z` behaviour to cancel workers at the dead line. #211
- Fix align of histogram #210

# 0.5.6 (2023-02-02)
Expand Down
9 changes: 6 additions & 3 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ pub struct ConnectionTime {
#[derive(Debug, Clone)]
/// a result for a request
pub struct RequestResult {
// When the query should started
pub start_latency_correction: Option<std::time::Instant>,
/// When the query started
pub start: std::time::Instant,
/// DNS + dialup
Expand All @@ -31,7 +33,7 @@ pub struct RequestResult {
impl RequestResult {
/// Duration the request takes.
pub fn duration(&self) -> std::time::Duration {
self.end - self.start
self.end - self.start_latency_correction.unwrap_or(self.start)
}
}

Expand Down Expand Up @@ -361,6 +363,7 @@ impl Client {
let end = std::time::Instant::now();

let result = RequestResult {
start_latency_correction: None,
start,
end,
status,
Expand Down Expand Up @@ -649,7 +652,7 @@ pub async fn work_with_qps_latency_correction(
let mut res = w.work().await;

if let Ok(request_result) = &mut res {
request_result.start = start;
request_result.start_latency_correction = Some(start);
}

let is_cancel = is_too_many_open_files(&res);
Expand Down Expand Up @@ -786,7 +789,7 @@ pub async fn work_until_with_qps_latency_correction(
let mut res = w.work().await;

if let Ok(request_result) = &mut res {
request_result.start = start;
request_result.start_latency_correction = Some(start);
}

let is_cancel = is_too_many_open_files(&res);
Expand Down

0 comments on commit 8478100

Please sign in to comment.