diff --git a/crates/api/src/lib.rs b/crates/api/src/lib.rs index 3b020a4..32c956d 100644 --- a/crates/api/src/lib.rs +++ b/crates/api/src/lib.rs @@ -39,6 +39,10 @@ pub struct View { pub previous: Option, pub timing: Timing, pub time_saved: TimeSaved, + /// What is known about how long each language takes to build, from saved + /// history. Sorted by compiles seen, largest first. + #[serde(default)] + pub build_times: Vec, /// Sorted by hits + misses, largest first. pub languages: Vec, /// Why compiles were not cacheable, largest first, e.g. ("crate-type", 562). @@ -131,11 +135,37 @@ pub struct Timing { #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] pub struct TimeSaved { pub seconds: f64, + /// The range the true saving falls in with 90% confidence (low, high), from + /// resampling the build times seen. `None` when there is too little data. + #[serde(default)] + pub interval_90: Option<(f64, f64)>, pub hits_left_out: u64, /// Plain-language account of how the figure was reached, for the hover note. pub note: String, } +/// The spread of build times seen for one language. sccache reports only running +/// totals, so each data point is the average over the builds that finished +/// between two readings ten seconds apart: often one build, sometimes a few. +#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] +pub struct BuildTimes { + pub language: String, + /// Builds seen. + pub compiles: u64, + pub mean_ms: f64, + pub median_ms: f64, + pub p90_ms: f64, + /// Histogram, shortest first, bin edges evenly spaced on a log scale. + pub bins: Vec, +} + +#[derive(Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize)] +pub struct Bin { + pub from_ms: f64, + pub to_ms: f64, + pub compiles: u64, +} + #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] pub struct Language { pub name: String,