Skip to content
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
8 changes: 8 additions & 0 deletions src/printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,7 @@ fn print_summary<W: Write>(

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,
Expand All @@ -638,6 +639,13 @@ fn print_summary<W: Write>(
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<http::StatusCode, usize> = res.status_code_distribution();
Expand Down
26 changes: 26 additions & 0 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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" }));
Expand Down
Loading