Skip to content
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

Freshly coded new client #24

Merged
merged 8 commits into from
Nov 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ authors = ["Harrison Burt <57491488+ChillFish8@users.noreply.github.com>", "Prog
edition = "2018"

[dependencies]
tokio = { version = "1.9.0", features = ["rt", "rt-multi-thread", "net", "macros"] }
hyper = { version = "0.14.11", features = ["runtime", "client", "http1", "http2"] }
tower = { version = "0.4.7", features = ["util"] }
rustls = "0.19.1"
tokio-rustls = "0.22.0"
rustls-native-certs = "0.5.0"
clap = "2.33.3"
anyhow = "1"
clap = "2"
colored = "2"
regex = "1.4.*"
rand = "0.8.3"
futures-util = "0.3"
http = "0.2"
hyper = { version = "0.14", features = ["runtime", "client", "http1", "http2"] }
native-tls = { version = "0.2", features = ["alpn"] }
pin-project-lite = "0.2"
regex = "1"
rand = "0.8"
serde_json = "1"
http = "0.2.4"
anyhow = "1"
tokio = { version = "1", features = ["rt", "rt-multi-thread", "net", "macros"] }
tokio-native-tls = "0.3"
tower = { version = "0.4", features = ["util"] }
7 changes: 7 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
unstable_features = true
combine_control_expr = false
imports_layout = "HorizontalVertical"
match_block_trailing_comma = true
imports_granularity = "Module"
group_imports = "StdExternalCrate"
max_width = 89
33 changes: 16 additions & 17 deletions src/bench.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use anyhow::{Error, Result};
use colored::*;
use std::fmt::Display;
use std::time::Duration;

use crate::http;
use anyhow::{anyhow, Result};
use colored::*;
use futures_util::StreamExt;

use crate::results::WorkerResult;
use crate::runtime;
use crate::utils::div_mod;
use crate::{http, runtime};

/// The customisable settings that build the benchmark's behaviour.
#[derive(Clone, Debug)]
Expand Down Expand Up @@ -48,7 +49,8 @@ pub fn start_benchmark(settings: BenchmarkSettings) {
}

if let Err(e) = rt.block_on(run(settings.clone())) {
eprintln!("failed to run benchmark round due to error: {:?}", e);
eprintln!();
eprintln!("{}", e);
return;
}

Expand Down Expand Up @@ -81,9 +83,9 @@ async fn run(settings: BenchmarkSettings) -> Result<()> {
)
.await;

let handles = match handles {
let mut handles = match handles {
Ok(v) => v,
Err(e) => return Err(Error::msg(format!("error parsing uri: {}", e))),
Err(e) => return Err(anyhow!("error parsing uri: {}", e)),
};

if !settings.display_json {
Expand All @@ -96,16 +98,10 @@ async fn run(settings: BenchmarkSettings) -> Result<()> {
}

let mut combiner = WorkerResult::default();
for handle in handles {
let result = match handle.await {
Ok(r) => r,
Err(e) => return Err(Error::msg(format!("error processing results: {}", e))),
};

if let Ok(stats) = result {
combiner = combiner.combine(stats);
} else if let Err(e) = result {
return Err(Error::msg(format!("error combining results: {}", e)));
while let Some(result) = handles.next().await {
match result.unwrap() {
Ok(stats) => combiner = combiner.combine(stats),
Err(e) => return Err(anyhow!("connection error: {}", e)),
}
}

Expand All @@ -128,6 +124,9 @@ async fn run(settings: BenchmarkSettings) -> Result<()> {
combiner.display_percentile_table();
}

// Display errors last.
combiner.display_errors();

Ok(())
}

Expand Down
1 change: 0 additions & 1 deletion src/error.rs

This file was deleted.

38 changes: 0 additions & 38 deletions src/http.rs

This file was deleted.

Loading