contrib: add benchmark scripts
This commit is contained in:
parent
0173db178a
commit
266b55a6f3
2 changed files with 71 additions and 0 deletions
31
contrib/bench_row.sh
Executable file
31
contrib/bench_row.sh
Executable file
|
@ -0,0 +1,31 @@
|
||||||
|
# run one or more benchmarks, for use together with bench_table.sh
|
||||||
|
# usage: ./bench_row.sh [-i] [-c crit_bench]..
|
||||||
|
|
||||||
|
{
|
||||||
|
git log --oneline | head -n1
|
||||||
|
|
||||||
|
while getopts i:c: flag; do
|
||||||
|
case "$flag" in
|
||||||
|
i)
|
||||||
|
cargo bench -p bench-iai 2>|/dev/null \
|
||||||
|
| awk -v b="$OPTARG" '
|
||||||
|
$0 == b {inside=1}
|
||||||
|
$0 == "" {inside=0}
|
||||||
|
inside && $1 == "Estimated" {print $3, $4, $5}
|
||||||
|
'
|
||||||
|
;;
|
||||||
|
c)
|
||||||
|
# try to reduce noise by selecting max throughput of multiple runs
|
||||||
|
for _ in $(seq 100); do
|
||||||
|
cargo bench -p bench-crit -- --quick "$OPTARG" 2>|/dev/null \
|
||||||
|
| awk 'NR == 2 {print $4}'
|
||||||
|
done | sort -rV | head -n1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
} | tr "\n" "\t"
|
||||||
|
|
||||||
|
echo
|
40
contrib/bench_table.sh
Executable file
40
contrib/bench_table.sh
Executable file
|
@ -0,0 +1,40 @@
|
||||||
|
# run benchmarks over a range of commits and assemble a table
|
||||||
|
# usage: ./contrib/bench_table.sh [-r RANGE] -- BENCHMARKS
|
||||||
|
|
||||||
|
range="master.."
|
||||||
|
while getopts r: flag; do
|
||||||
|
case "$flag" in
|
||||||
|
r) range=$OPTARG;;
|
||||||
|
*) exit 1;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shift $((OPTIND-1))
|
||||||
|
|
||||||
|
[ -z "$*" ] && exit 1
|
||||||
|
|
||||||
|
make bench || exit 1
|
||||||
|
|
||||||
|
current="$(git rev-parse --abbrev-ref HEAD)"
|
||||||
|
|
||||||
|
trap "git checkout $current" EXIT
|
||||||
|
|
||||||
|
< /proc/cpuinfo grep "model name" | head -n1
|
||||||
|
{
|
||||||
|
{
|
||||||
|
echo "commit"
|
||||||
|
OPTIND=1
|
||||||
|
while getopts i:c: flag "$@"; do
|
||||||
|
case "$flag" in
|
||||||
|
i) echo "iai:$OPTARG [cycles]";;
|
||||||
|
c) echo "criterion:$OPTARG [MB/s]";;
|
||||||
|
*) exit 1
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
} | tr "\n" "\t"
|
||||||
|
echo
|
||||||
|
set -x
|
||||||
|
for commit in $(git rev-list --reverse --topo-order "$range"); do
|
||||||
|
git checkout "$commit" >/dev/null
|
||||||
|
./contrib/bench_row.sh "$@" | tee /proc/self/fd/2
|
||||||
|
done
|
||||||
|
} | column -t -s"$(printf "\t")"
|
Loading…
Reference in a new issue