Skip to content

Commit 9ffdb25

Browse files
authored
Merge pull request #1668 from Kobzol/runtime-precise-skip
Make skipping of already benchmarked runtime benchmarks more precise
2 parents 65eb109 + 7c67ca6 commit 9ffdb25

File tree

3 files changed

+41
-15
lines changed

3 files changed

+41
-15
lines changed

collector/src/bin/collector.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,16 @@ struct RuntimeBenchmarkConfig {
8888
iterations: u32,
8989
}
9090

91+
impl RuntimeBenchmarkConfig {
92+
fn new(suite: BenchmarkSuite, filter: BenchmarkFilter, iterations: u32) -> Self {
93+
Self {
94+
runtime_suite: suite.filter(&filter),
95+
filter,
96+
iterations,
97+
}
98+
}
99+
}
100+
91101
struct SharedBenchmarkConfig {
92102
artifact_id: ArtifactId,
93103
toolchain: Toolchain,
@@ -671,11 +681,11 @@ fn main_result() -> anyhow::Result<i32> {
671681
artifact_id,
672682
toolchain,
673683
};
674-
let config = RuntimeBenchmarkConfig {
684+
let config = RuntimeBenchmarkConfig::new(
675685
runtime_suite,
676-
filter: BenchmarkFilter::new(local.exclude, local.include),
686+
BenchmarkFilter::new(local.exclude, local.include),
677687
iterations,
678-
};
688+
);
679689
run_benchmarks(&mut rt, conn, shared, None, Some(config))?;
680690
Ok(0)
681691
}
@@ -1149,11 +1159,11 @@ fn bench_published_artifact(
11491159
is_self_profile: false,
11501160
bench_rustc: false,
11511161
}),
1152-
Some(RuntimeBenchmarkConfig {
1162+
Some(RuntimeBenchmarkConfig::new(
11531163
runtime_suite,
1154-
filter: BenchmarkFilter::keep_all(),
1155-
iterations: DEFAULT_RUNTIME_ITERATIONS,
1156-
}),
1164+
BenchmarkFilter::keep_all(),
1165+
DEFAULT_RUNTIME_ITERATIONS,
1166+
)),
11571167
)
11581168
}
11591169

collector/src/runtime/benchmark.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,29 @@ pub struct BenchmarkSuite {
3838
}
3939

4040
impl BenchmarkSuite {
41-
pub fn total_benchmark_count(&self) -> u64 {
42-
self.benchmark_names().count() as u64
41+
/// Returns a new suite containing only groups that contains at least a single benchmark
42+
/// that matches the filter.
43+
pub fn filter(self, filter: &BenchmarkFilter) -> Self {
44+
let BenchmarkSuite {
45+
groups,
46+
_tmp_artifacts_dir,
47+
} = self;
48+
49+
Self {
50+
groups: groups
51+
.into_iter()
52+
.filter(|group| {
53+
group.benchmark_names.iter().any(|benchmark| {
54+
passes_filter(
55+
benchmark,
56+
filter.exclude.as_deref(),
57+
filter.include.as_deref(),
58+
)
59+
})
60+
})
61+
.collect(),
62+
_tmp_artifacts_dir,
63+
}
4364
}
4465

4566
pub fn filtered_benchmark_count(&self, filter: &BenchmarkFilter) -> u64 {

collector/src/runtime/mod.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,8 @@ pub async fn bench_runtime(
3030
filter: BenchmarkFilter,
3131
iterations: u32,
3232
) -> anyhow::Result<()> {
33-
let total_benchmark_count = suite.total_benchmark_count();
3433
let filtered = suite.filtered_benchmark_count(&filter);
35-
println!(
36-
"Executing {} benchmarks ({} filtered out)\n",
37-
filtered,
38-
total_benchmark_count - filtered
39-
);
34+
println!("Executing {} benchmarks\n", filtered);
4035

4136
let rustc_perf_version = get_rustc_perf_commit();
4237
let mut benchmark_index = 0;

0 commit comments

Comments
 (0)