@@ -37,6 +37,10 @@ Runs <command> over and over again with different seeds for Miri. The MIRIFLAGS
37
37
variable is set to its original value appended with ` -Zmiri-seed=$SEED` for
38
38
many different seeds.
39
39
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
+
40
44
ENVIRONMENT VARIABLES
41
45
42
46
MIRI_SYSROOT:
@@ -47,6 +51,11 @@ Pass extra flags to all cargo invocations.
47
51
EOF
48
52
)
49
53
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
+
50
59
# Determine command.
51
60
COMMAND=" $1 "
52
61
[ $# -gt 0 ] && shift
@@ -60,14 +69,23 @@ many-seeds)
60
69
done
61
70
exit 0
62
71
;;
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
+ ;;
63
86
esac
64
87
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
71
89
# Determine some toolchain properties
72
90
TARGET=$( rustc +$TOOLCHAIN --version --verbose | grep " ^host:" | cut -d ' ' -f 2)
73
91
SYSROOT=$( rustc +$TOOLCHAIN --print sysroot)
0 commit comments