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
78 changes: 76 additions & 2 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,57 @@
"p99.99"
]
},
"firstByteHistogram": {
"description": "The histogram of first byte time in seconds. The key is the first byte time in seconds and the value is the number of requests",
"type": "object",
"additionalProperties": {
"type": "integer"
}
},
"firstBytePercentiles": {
"description": "The first byte percentiles in seconds",
"type": "object",
"properties": {
"p10": {
"type": "number"
},
"p25": {
"type": "number"
},
"p50": {
"type": "number"
},
"p75": {
"type": "number"
},
"p90": {
"type": "number"
},
"p95": {
"type": "number"
},
"p99": {
"type": "number"
},
"p99.9": {
"type": "number"
},
"p99.99": {
"type": "number"
}
},
"required": [
"p10",
"p25",
"p50",
"p75",
"p90",
"p95",
"p99",
"p99.9",
"p99.99"
]
},
"responseTimeHistogramSuccessful": {
"description": "Only present if `--stats-success-breakdown` argument is passed. The histogram of response time in seconds for successful requests. The key is the response time in seconds and the value is the number of requests",
"type": "object",
Expand Down Expand Up @@ -323,11 +374,32 @@
"fastest",
"slowest"
]
},
"firstByte": {
"description": "The time to first byte in seconds",
"type": "object",
"properties": {
"average": {
"type": "number"
},
"fastest": {
"type": "number"
},
"slowest": {
"type": "number"
}
},
"required": [
"average",
"fastest",
"slowest"
]
}
},
"required": [
"DNSDialup",
"DNSLookup"
"DNSLookup",
"firstByte"
]
},
"statusCodeDistribution": {
Expand All @@ -354,9 +426,11 @@
"summary",
"responseTimeHistogram",
"latencyPercentiles",
"firstByteHistogram",
"firstBytePercentiles",
"rps",
"details",
"statusCodeDistribution",
"errorDistribution"
]
}
}
28 changes: 28 additions & 0 deletions src/printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ fn print_json<W: Write>(
dns_dialup: Triple,
#[serde(rename = "DNSLookup")]
dns_lookup: Triple,
#[serde(rename = "firstByte")]
first_byte: Triple,
}

#[derive(Serialize)]
Expand All @@ -198,6 +200,10 @@ fn print_json<W: Write>(
response_time_histogram: BTreeMap<String, usize>,
#[serde(rename = "latencyPercentiles")]
latency_percentiles: BTreeMap<String, f64>,
#[serde(rename = "firstByteHistogram")]
first_byte_histogram: BTreeMap<String, usize>,
#[serde(rename = "firstBytePercentiles")]
first_byte_percentiles: BTreeMap<String, f64>,
#[serde(
rename = "responseTimeHistogramSuccessful",
skip_serializing_if = "Option::is_none"
Expand Down Expand Up @@ -255,6 +261,20 @@ fn print_json<W: Write>(
.map(|(p, v)| (format!("p{p}"), v))
.collect();

let first_byte_statistics = res.first_byte_all_statistics();

let first_byte_histogram = first_byte_statistics
.histogram
.into_iter()
.map(|(k, v)| (k.to_string(), v))
.collect();

let first_byte_percentiles = first_byte_statistics
.percentiles
.into_iter()
.map(|(p, v)| (format!("p{p}"), v))
.collect();

let mut response_time_histogram_successful: Option<BTreeMap<String, usize>> = None;
let mut latency_percentiles_successful: Option<BTreeMap<String, f64>> = None;
let mut response_time_histogram_not_successful: Option<BTreeMap<String, usize>> = None;
Expand Down Expand Up @@ -345,6 +365,7 @@ fn print_json<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();

let details = Details {
dns_dialup: Triple {
Expand All @@ -357,6 +378,11 @@ fn print_json<W: Write>(
fastest: dns_lookup_stat.min(),
slowest: dns_lookup_stat.max(),
},
first_byte: Triple {
average: first_byte_stat.mean(),
fastest: first_byte_stat.min(),
slowest: first_byte_stat.max(),
},
};

serde_json::to_writer_pretty(
Expand All @@ -365,6 +391,8 @@ fn print_json<W: Write>(
summary,
response_time_histogram,
latency_percentiles,
first_byte_histogram,
first_byte_percentiles,
response_time_histogram_successful,
latency_percentiles_successful,
response_time_histogram_not_successful,
Expand Down
16 changes: 16 additions & 0 deletions src/result_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ impl ResultData {
.collect()
}

pub fn first_byte_stat(&self) -> MinMaxMean {
self.success
.iter()
.filter_map(|r| r.first_byte.map(|fb| (fb - r.start).as_secs_f64()))
.collect()
}

pub fn total_data(&self) -> usize {
self.success.iter().map(|r| r.len_bytes).sum()
}
Expand All @@ -155,6 +162,15 @@ impl ResultData {
Statistics::new(&mut data)
}

pub fn first_byte_all_statistics(&self) -> Statistics {
let mut data = self
.success
.iter()
.filter_map(|r| r.first_byte.map(|fb| (fb - r.start).as_secs_f64()))
.collect::<Vec<_>>();
Statistics::new(&mut data)
}

pub fn duration_successful_statistics(&self) -> Statistics {
let mut data = self
.success
Expand Down