use serde::Deserialize;
#[derive(Deserialize)]
pub(crate) struct BenchmarkMeta {
pub(crate) group_id: String,
pub(crate) function_id: String,
pub(crate) value_str: Option<String>,
pub(crate) throughput: Option<Throughput>,
pub(crate) full_id: String,
}
#[derive(Deserialize)]
#[serde(rename_all = "PascalCase")]
#[allow(dead_code)]
pub(crate) enum Throughput {
Bytes(u64),
Elements(u64),
}
#[derive(Deserialize)]
pub(crate) struct Estimates {
pub(crate) slope: Option<Estimate>,
pub(crate) mean: Estimate,
}
#[derive(Deserialize)]
pub(crate) struct Estimate {
pub(crate) point_estimate: f64,
}
#[derive(Deserialize)]
pub(crate) struct ChangeEstimates {
pub(crate) mean: ChangeEstimate,
}
#[derive(Deserialize)]
pub(crate) struct ChangeEstimate {
pub(crate) point_estimate: f64,
}
pub(crate) struct ChangeInfo {
pub(crate) point_estimate: f64,
}
pub(crate) struct BenchEntry {
pub(crate) full_id: String,
pub(crate) group_id: String,
pub(crate) function_id: String,
pub(crate) value_str: Option<String>,
pub(crate) estimate_ns: f64,
#[allow(dead_code)]
pub(crate) throughput: Option<Throughput>,
pub(crate) change: Option<ChangeInfo>,
}
impl BenchEntry {
pub(crate) fn column(&self) -> &str {
if self.value_str.is_some() {
return &self.function_id;
}
match self.function_id.rfind('/') {
Some(idx) => &self.function_id[..idx],
None => &self.function_id,
}
}
pub(crate) fn row(&self) -> Option<&str> {
if let Some(ref v) = self.value_str {
return Some(v.as_str());
}
self.function_id
.rfind('/')
.map(|idx| &self.function_id[idx + 1..])
}
}