mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-02 18:55:32 +00:00
aquatic_bench: start work on fixing it: create new connect bencher
This commit is contained in:
parent
6c4013ca55
commit
f4ca9c2795
6 changed files with 121 additions and 101 deletions
|
|
@ -1,5 +1,36 @@
|
|||
use std::time::Duration;
|
||||
|
||||
use indicatif::{ProgressBar, ProgressStyle};
|
||||
use num_format::{Locale, ToFormattedString};
|
||||
|
||||
|
||||
pub const PARETO_SHAPE: f64 = 0.1;
|
||||
pub const NUM_INFO_HASHES: usize = 10_000;
|
||||
|
||||
/// Save memory by not allocating more per request
|
||||
pub const MAX_REQUEST_BYTES: usize = 256;
|
||||
|
||||
pub fn create_progress_bar(name: &str, iterations: u64) -> ProgressBar {
|
||||
let t = format!("{:<16} {}", name, "{wide_bar} {pos:>2}/{len:>2}");
|
||||
let style = ProgressStyle::default_bar().template(&t);
|
||||
|
||||
ProgressBar::new(iterations).with_style(style)
|
||||
}
|
||||
|
||||
|
||||
pub fn print_results(
|
||||
request_type: &str,
|
||||
num_responses: usize,
|
||||
duration: Duration,
|
||||
) {
|
||||
let per_second = (
|
||||
(num_responses as f64 / (duration.as_micros() as f64 / 1000000.0)
|
||||
) as usize).to_formatted_string(&Locale::se);
|
||||
|
||||
let time_per_request = duration.as_nanos() as f64 / (num_responses as f64);
|
||||
|
||||
println!(
|
||||
"{} {:>10} requests/second, {:>8.2} ns/request",
|
||||
request_type,
|
||||
per_second,
|
||||
time_per_request,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue