From e055e8159ccf52fb79f37d1e3f47ba031212b8ed Mon Sep 17 00:00:00 2001 From: ZensykU2 Date: Thu, 22 Oct 2026 14:32:48 +0200 Subject: [PATCH] Show first byte stats in text output --- src/printer.rs | 8 ++++++++ tests/tests.rs | 26 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/printer.rs b/src/printer.rs index 1ae3d597..91d4b499 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -617,6 +617,7 @@ fn print_summary( let dns_dialup_stat = res.dns_dialup_stat(); let dns_lookup_stat = res.dns_lookup_stat(); + let first_byte_stat = res.first_byte_stat(); writeln!( w, @@ -638,6 +639,13 @@ fn print_summary( dns_lookup_stat.min() / timescale.as_secs_f64(), dns_lookup_stat.max() / timescale.as_secs_f64() )?; + writeln!( + w, + " First byte:\t{:.4} {timescale}, {:.4} {timescale}, {:.4} {timescale}", + first_byte_stat.mean() / timescale.as_secs_f64(), + first_byte_stat.min() / timescale.as_secs_f64(), + first_byte_stat.max() / timescale.as_secs_f64() + )?; writeln!(w)?; let status_dist: BTreeMap = res.status_code_distribution(); diff --git a/tests/tests.rs b/tests/tests.rs index 97b213f4..a5a8f287 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -1325,6 +1325,32 @@ async fn test_json_schema(#[case] success_breakdown: bool) { } } +#[tokio::test] +async fn test_text_output_first_byte() { + let app = Router::new().route("/", get(|| async move { "Hello World" })); + + let (listener, port) = bind_port().await; + tokio::spawn(async { axum::serve(listener, app).await }); + + let temp_path = tempfile::NamedTempFile::new().unwrap().into_temp_path(); + run_command([ + OsStr::new("--no-tui"), + OsStr::new("-n"), + OsStr::new("5"), + OsStr::new(&format!("http://127.0.0.1:{port}/")), + OsStr::new("--output"), + temp_path.as_os_str(), + ]) + .await; + + let output = std::fs::read_to_string(&temp_path).unwrap(); + + assert!( + output.contains(" First byte:\t"), + "missing first byte line in text output:\n{output}" + ); +} + #[tokio::test] async fn test_csv_output() { let app = Router::new().route("/", get(|| async move { "Hello World" }));