Skip to content

Commit e7d3682

Browse files
committed
./miri bench: add a flag to skip the install step
1 parent 74b0311 commit e7d3682

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

ci/ci.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export RUSTFLAGS="-D warnings"
1818
export CARGO_INCREMENTAL=0
1919
export CARGO_EXTRA_FLAGS="--locked"
2020

21-
# Determine configuration for installed build (used by test-cargo-miri).
21+
# Determine configuration for installed build (used by test-cargo-miri and `./miri bench`).
2222
echo "Installing release version of Miri"
2323
time ./miri install
2424

@@ -73,7 +73,7 @@ function run_tests {
7373
fi
7474
if [ -n "${TEST_BENCH-}" ]; then
7575
# Check that the benchmarks build and run, but only once.
76-
time HYPERFINE="hyperfine -w0 -r1 --show-output" ./miri bench $TARGET_FLAG
76+
time HYPERFINE="hyperfine -w0 -r1 --show-output" ./miri bench $TARGET_FLAG --no-install
7777
fi
7878
# Smoke-test `./miri run --dep`.
7979
./miri run $TARGET_FLAG --dep tests/pass-dep/getrandom.rs

miri-script/src/commands.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ impl Command {
179179
Command::Doc { flags } => Self::doc(flags),
180180
Command::Fmt { flags } => Self::fmt(flags),
181181
Command::Clippy { flags } => Self::clippy(flags),
182-
Command::Bench { target, benches } => Self::bench(target, benches),
182+
Command::Bench { target, no_install, benches } =>
183+
Self::bench(target, no_install, benches),
183184
Command::Toolchain { flags } => Self::toolchain(flags),
184185
Command::RustcPull { commit } => Self::rustc_pull(commit.clone()),
185186
Command::RustcPush { github_user, branch } => Self::rustc_push(github_user, branch),
@@ -378,16 +379,18 @@ impl Command {
378379
Ok(())
379380
}
380381

381-
fn bench(target: Option<String>, benches: Vec<String>) -> Result<()> {
382+
fn bench(target: Option<String>, no_install: bool, benches: Vec<String>) -> Result<()> {
382383
// The hyperfine to use
383384
let hyperfine = env::var("HYPERFINE");
384385
let hyperfine = hyperfine.as_deref().unwrap_or("hyperfine -w 1 -m 5 --shell=none");
385386
let hyperfine = shell_words::split(hyperfine)?;
386387
let Some((program_name, args)) = hyperfine.split_first() else {
387388
bail!("expected HYPERFINE environment variable to be non-empty");
388389
};
389-
// Make sure we have an up-to-date Miri installed and selected the right toolchain.
390-
Self::install(vec![])?;
390+
if !no_install {
391+
// Make sure we have an up-to-date Miri installed and selected the right toolchain.
392+
Self::install(vec![])?;
393+
}
391394

392395
let sh = Shell::new()?;
393396
sh.change_dir(miri_dir()?);

miri-script/src/main.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ pub enum Command {
6969
/// Runs the benchmarks from bench-cargo-miri in hyperfine. hyperfine needs to be installed.
7070
Bench {
7171
target: Option<String>,
72+
/// When `true`, skip the `./miri install` step.
73+
no_install: bool,
7274
/// List of benchmarks to run. By default all benchmarks are run.
7375
benches: Vec<String>,
7476
},
@@ -121,9 +123,11 @@ install`. Sets up the rpath such that the installed binary should work in any
121123
working directory. Note that the binaries are placed in the `miri` toolchain
122124
sysroot, to prevent conflicts with other toolchains.
123125
124-
./miri bench [--target <target>] <benches>:
126+
./miri bench [--target <target>] [--no-install] <benches>:
125127
Runs the benchmarks from bench-cargo-miri in hyperfine. hyperfine needs to be installed.
126128
<benches> can explicitly list the benchmarks to run; by default, all of them are run.
129+
By default, this runs `./miri install` to ensure the latest local Miri is being benchmarked;
130+
`--no-install` can be used to skip that step.
127131
128132
./miri toolchain <flags>:
129133
Update and activate the rustup toolchain 'miri' to the commit given in the
@@ -218,16 +222,19 @@ fn main() -> Result<()> {
218222
Some("bench") => {
219223
let mut target = None;
220224
let mut benches = Vec::new();
225+
let mut no_install = false;
221226
loop {
222227
if let Some(val) = args.get_long_opt("target")? {
223228
target = Some(val);
229+
} else if args.get_long_flag("no-install")? {
230+
no_install = true;
224231
} else if let Some(flag) = args.get_other() {
225232
benches.push(flag);
226233
} else {
227234
break;
228235
}
229236
}
230-
Command::Bench { target, benches }
237+
Command::Bench { target, benches, no_install }
231238
}
232239
Some("toolchain") => Command::Toolchain { flags: args.remainder() },
233240
Some("rustc-pull") => {

0 commit comments

Comments
 (0)