|
| 1 | +use collector::benchmark::category::Category; |
| 2 | +use collector::benchmark::BenchmarkConfig; |
| 3 | +use lazy_static::lazy_static; |
| 4 | +use rust_embed::RustEmbed; |
| 5 | +use std::path::Path; |
1 | 6 | use std::sync::Arc;
|
2 | 7 |
|
3 | 8 | use crate::api::{dashboard, ServerResult};
|
@@ -74,23 +79,14 @@ pub async fn handle_dashboard(ctxt: Arc<SiteCtxt>) -> ServerResult<dashboard::Re
|
74 | 79 | .collect::<Vec<_>>(),
|
75 | 80 | );
|
76 | 81 |
|
| 82 | + lazy_static! { |
| 83 | + static ref STABLE_BENCHMARKS: Vec<String> = get_stable_benchmarks(); |
| 84 | + } |
| 85 | + |
77 | 86 | let query = selector::Query::new()
|
78 |
| - // FIXME: don't hardcode the stabilized benchmarks |
79 |
| - // This list was found via: |
80 |
| - // `rg supports.stable collector/compile-benchmarks/ -tjson -c --sort path` |
81 | 87 | .set(
|
82 | 88 | selector::Tag::Benchmark,
|
83 |
| - selector::Selector::Subset(vec![ |
84 |
| - "encoding", |
85 |
| - "futures", |
86 |
| - "html5ever", |
87 |
| - "inflate", |
88 |
| - "piston-image", |
89 |
| - "regex", |
90 |
| - "style-servo", |
91 |
| - "syn", |
92 |
| - "tokio-webpush-simple", |
93 |
| - ]), |
| 89 | + selector::Selector::Subset(STABLE_BENCHMARKS.clone()), |
94 | 90 | )
|
95 | 91 | .set(selector::Tag::Metric, selector::Selector::One("wall-time"));
|
96 | 92 |
|
@@ -153,6 +149,44 @@ pub async fn handle_dashboard(ctxt: Arc<SiteCtxt>) -> ServerResult<dashboard::Re
|
153 | 149 | })
|
154 | 150 | }
|
155 | 151 |
|
| 152 | +#[derive(RustEmbed)] |
| 153 | +#[folder = "../collector/compile-benchmarks"] |
| 154 | +#[include = "*/perf-config.json"] |
| 155 | +struct EmbeddedBenchmarks; |
| 156 | + |
| 157 | +/// The configurations of compile-time benchmarks are embedded directly within the binary using |
| 158 | +/// the `Benchmarks` struct. |
| 159 | +/// |
| 160 | +/// Here we parse the benchmarks configurations and return only stable benchmarks. |
| 161 | +fn get_stable_benchmarks() -> Vec<String> { |
| 162 | + EmbeddedBenchmarks::iter() |
| 163 | + .filter_map(|path| EmbeddedBenchmarks::get(&path).map(|file| (file, path))) |
| 164 | + .filter_map(|(file, path)| { |
| 165 | + let config: BenchmarkConfig = match serde_json::from_slice(&file.data) { |
| 166 | + Ok(config) => config, |
| 167 | + Err(error) => { |
| 168 | + log::error!( |
| 169 | + "Cannot deserialized stored perf-config.json from {path}: {error:?}" |
| 170 | + ); |
| 171 | + return None; |
| 172 | + } |
| 173 | + }; |
| 174 | + if config.category() == Category::Stable { |
| 175 | + Some( |
| 176 | + Path::new(path.as_ref()) |
| 177 | + .parent() |
| 178 | + .unwrap() |
| 179 | + .to_str() |
| 180 | + .unwrap() |
| 181 | + .to_string(), |
| 182 | + ) |
| 183 | + } else { |
| 184 | + None |
| 185 | + } |
| 186 | + }) |
| 187 | + .collect() |
| 188 | +} |
| 189 | + |
156 | 190 | pub struct ByProfile<T> {
|
157 | 191 | pub check: T,
|
158 | 192 | pub debug: T,
|
|
0 commit comments