bench: add announce and scrape benchmarks

Only announce seems to be faster with more threads
This commit is contained in:
Joakim Frostegård 2020-04-13 03:23:17 +02:00
parent f4ca9c2795
commit b9a9a82207
6 changed files with 269 additions and 367 deletions

View file

@ -1,7 +1,5 @@
use std::time::Duration;
use indicatif::{ProgressBar, ProgressStyle};
use num_format::{Locale, ToFormattedString};
pub const PARETO_SHAPE: f64 = 0.1;
@ -14,23 +12,3 @@ pub fn create_progress_bar(name: &str, iterations: u64) -> ProgressBar {
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,
);
}