@@ -37,6 +37,10 @@ Runs <command> over and over again with different seeds for Miri. The MIRIFLAGS
3737variable is set to its original value appended with ` -Zmiri-seed=$SEED` for
3838many different seeds.
3939
40+ ./miri bench <benches>:
41+ Runs the benchmarks from bench-cargo-miri in hyperfine. hyperfine needs to be installed.
42+ <benches> can explicitly list the benchmarks to run; by default, all of them are run.
43+
4044 ENVIRONMENT VARIABLES
4145
4246MIRI_SYSROOT:
@@ -47,6 +51,11 @@ Pass extra flags to all cargo invocations.
4751EOF
4852)
4953
54+ # # Preparation
55+ # macOS does not have a useful readlink/realpath so we have to use Python instead...
56+ MIRIDIR=$( python3 -c ' import os, sys; print(os.path.dirname(os.path.realpath(sys.argv[1])))' " $0 " )
57+ TOOLCHAIN=$( cd " $MIRIDIR " ; rustup show active-toolchain | head -n 1 | cut -d ' ' -f 1)
58+
5059# Determine command.
5160COMMAND=" $1 "
5261[ $# -gt 0 ] && shift
@@ -60,14 +69,23 @@ many-seeds)
6069 done
6170 exit 0
6271 ;;
72+ bench)
73+ # Make sure we have an up-to-date Miri installed
74+ " $0 " install
75+ # Run the requested benchmarks
76+ if [ -z " $@ " ]; then
77+ BENCHES=( $( ls " $MIRIDIR /bench-cargo-miri" ) )
78+ else
79+ BENCHES=(" $@ " )
80+ fi
81+ for BENCH in " ${BENCHES[@]} " ; do
82+ hyperfine -w 1 -m 5 --shell=none " cargo +$TOOLCHAIN miri run --manifest-path bench-cargo-miri/$BENCH /Cargo.toml"
83+ done
84+ exit 0
85+ ;;
6386esac
6487
65- # # Preparation
66- # macOS does not have a useful readlink/realpath so we have to use Python instead...
67- MIRIDIR=$( python3 -c ' import os, sys; print(os.path.dirname(os.path.realpath(sys.argv[1])))' " $0 " )
68- # Determine toolchain *in the Miri dir* and use that.
69- TOOLCHAIN=$( cd " $MIRIDIR " ; rustup show active-toolchain | head -n 1 | cut -d ' ' -f 1)
70-
88+ # # Prepare the environment
7189# Determine some toolchain properties
7290TARGET=$( rustc +$TOOLCHAIN --version --verbose | grep " ^host:" | cut -d ' ' -f 2)
7391SYSROOT=$( rustc +$TOOLCHAIN --print sysroot)
0 commit comments