Skip to content

Commit cb2639c

Browse files
authored
Merge pull request #1443 from rust-lang/excluded-scenarios
Add the option to exclude certain scenarios in `perf-config.json`
2 parents 6bf3790 + 01ac624 commit cb2639c

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

collector/src/benchmark/mod.rs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,16 @@ struct BenchmarkConfig {
4141
touch_file: Option<String>,
4242

4343
category: Category,
44+
4445
/// Profiles that are not useful for this benchmark.
4546
/// They will be ignored during benchmarking.
4647
#[serde(default)]
4748
excluded_profiles: HashSet<Profile>,
49+
50+
/// Scenarios that are not useful for this benchmark.
51+
/// They will be ignored during benchmarking.
52+
#[serde(default)]
53+
excluded_scenarios: HashSet<Scenario>,
4854
}
4955

5056
#[derive(Ord, PartialOrd, Eq, PartialEq, Clone, Hash)]
@@ -185,6 +191,11 @@ impl Benchmark {
185191
compiler: Compiler<'_>,
186192
iterations: Option<usize>,
187193
) -> anyhow::Result<()> {
194+
if self.config.disabled {
195+
eprintln!("Skipping {}: disabled", self.name);
196+
bail!("disabled benchmark");
197+
}
198+
188199
let iterations = iterations.unwrap_or(self.config.runs);
189200

190201
let profiles: Vec<Profile> = profiles
@@ -193,16 +204,22 @@ impl Benchmark {
193204
.filter(|profile| !self.config.excluded_profiles.contains(profile))
194205
.collect();
195206

196-
if self.config.disabled {
197-
eprintln!("Skipping {}: disabled", self.name);
198-
bail!("disabled benchmark");
199-
}
200-
201207
if profiles.is_empty() {
202208
eprintln!("Skipping {}: no profiles selected", self.name);
203209
return Ok(());
204210
}
205211

212+
let scenarios: Vec<Scenario> = scenarios
213+
.into_iter()
214+
.copied()
215+
.filter(|scenario| !self.config.excluded_scenarios.contains(scenario))
216+
.collect();
217+
218+
if scenarios.is_empty() {
219+
eprintln!("Skipping {}: no scenarios selected", self.name);
220+
return Ok(());
221+
}
222+
206223
eprintln!("Preparing {}", self.name);
207224
let profile_dirs = profiles
208225
.iter()

collector/src/benchmark/scenario.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, clap::ArgEnum)]
1+
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, clap::ArgEnum, serde::Deserialize)]
22
#[clap(rename_all = "PascalCase")]
33
pub enum Scenario {
44
Full,

0 commit comments

Comments
 (0)