Skip to content

Commit 8029302

Browse files
committed
Allow specifying the number of executed iterations for runtime benchmarks
1 parent d386f1e commit 8029302

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

collector/src/bin/collector.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,10 @@ enum Commands {
575575
/// Include only benchmarks matching a prefix in this comma-separated list
576576
#[clap(long)]
577577
include: Option<String>,
578+
579+
/// How many iterations of each benchmark should be executed.
580+
#[clap(long, default_value = "5")]
581+
iterations: u32,
578582
},
579583
/// Benchmarks a local rustc
580584
BenchLocal {
@@ -706,12 +710,14 @@ fn main_result() -> anyhow::Result<i32> {
706710
id,
707711
exclude,
708712
include,
713+
iterations,
709714
} => {
710715
bench_runtime(
711716
&rustc,
712717
id.as_deref(),
713718
BenchmarkFilter::new(exclude, include),
714719
runtime_benchmark_dir,
720+
iterations,
715721
)?;
716722
Ok(0)
717723
}

collector/src/runtime/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub fn bench_runtime(
1818
id: Option<&str>,
1919
filter: BenchmarkFilter,
2020
benchmark_dir: PathBuf,
21+
iterations: u32,
2122
) -> anyhow::Result<()> {
2223
let toolchain = get_local_toolchain(&[Profile::Opt], rustc, None, None, id, "")?;
2324
let output = compile_runtime_benchmark_binaries(&toolchain, &benchmark_dir)?;
@@ -33,7 +34,7 @@ pub fn bench_runtime(
3334

3435
let mut benchmark_index = 0;
3536
for binary in suite.groups {
36-
for message in execute_runtime_benchmark_binary(&binary.binary, &filter)? {
37+
for message in execute_runtime_benchmark_binary(&binary.binary, &filter, iterations)? {
3738
let message = message.map_err(|err| {
3839
anyhow::anyhow!(
3940
"Cannot parse BenchmarkMessage from benchmark {}: {err:?}",
@@ -65,13 +66,16 @@ pub fn bench_runtime(
6566
fn execute_runtime_benchmark_binary(
6667
binary: &Path,
6768
filter: &BenchmarkFilter,
69+
iterations: u32,
6870
) -> anyhow::Result<impl Iterator<Item = anyhow::Result<BenchmarkMessage>>> {
6971
// Turn off ASLR
7072
let mut command = Command::new("setarch");
7173
command.arg(std::env::consts::ARCH);
7274
command.arg("-R");
7375
command.arg(binary);
7476
command.arg("run");
77+
command.arg("--iterations");
78+
command.arg(&iterations.to_string());
7579

7680
if let Some(ref exclude) = filter.exclude {
7781
command.args(&["--exclude", exclude]);

0 commit comments

Comments
 (0)