Skip to content

Commit

Permalink
Merge pull request #17 from programatik29/master
Browse files Browse the repository at this point in the history
ignore all errors by default
  • Loading branch information
ChillFish8 authored Sep 8, 2021
2 parents 15625b9 + 5bef969 commit 17d9acf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
13 changes: 11 additions & 2 deletions src/proto/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@ where
let start = Instant::now();
let counter = Arc::new(AtomicUsize::new(0));

let mut connection = self.connect_retry(start, self.time_for, &counter).await?;
let mut connection = match self.connect_retry(start, self.time_for, &counter).await {
Ok(conn) => conn,
Err(_) => {
return Ok(WorkerResult::default());
}
};

let mut times: Vec<Duration> = Vec::with_capacity(self.predicted_size);

Expand All @@ -75,7 +80,11 @@ where
}
},
_ = (&mut connection.handle) => {
connection = self.connect_retry(start, self.time_for, &counter).await?;
match self.connect_retry(start, self.time_for, &counter).await {
Ok(conn) => connection = conn,
// Errors are ignored currently.
Err(_) => break,
}
}
};
}
Expand Down
6 changes: 2 additions & 4 deletions src/results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ fn get_percentile(request_times: &Vec<Duration>, pct: f64) -> Duration {
}

let e = format!("failed to calculate P{} avg latency", (1.0 - pct) * 100f64);
let pct = request_times
.chunks(len as usize)
.next()
.expect(&e);
let pct = request_times.chunks(len as usize).next().expect(&e);

let total: f64 = pct.iter().map(|dur| dur.as_secs_f64()).sum();

Expand All @@ -26,6 +23,7 @@ fn get_percentile(request_times: &Vec<Duration>, pct: f64) -> Duration {
}

/// Contains and handles results from the workers
#[derive(Default)]
pub struct WorkerResult {
/// The total time taken for each worker.
pub total_times: Vec<Duration>,
Expand Down

0 comments on commit 17d9acf

Please sign in to comment.