worldstone: add -s for statistical profiling

This commit is contained in:
Ben Gras 2012-09-05 23:42:41 +02:00
parent 7047e014c9
commit 24776434f5
2 changed files with 13 additions and 1 deletions

View file

@ -6,6 +6,7 @@
.Nd shell script to consistently execute benchmarks
.Sh SYNOPSIS
.Nm worldstone
.Op Fl s
.Op Fl n Ar iterations
.Op Fl c Ar command
.Op Fl p Ar command
@ -44,6 +45,11 @@ branch in /usr/src.
The options are as follows:
.Bl -tag -width Ds
.It Fl s
If set, perform statistical profiling by invoking
.Xr profile 1
and executing sprofalyze, suitable for feeding to sprofdiff. This
requires building world with SPROFILE.
.It Fl n Ar iterations
Set the number of iterations to perform, after the initial run.
The default is 5.

View file

@ -7,9 +7,10 @@ TAG=time.$(basename $(git --git-dir=/usr/src/.git describe --all --dirty))
set -e
while getopts "n:d:p:c:r:" c
while getopts "n:d:p:c:r:s" c
do
case "$c" in
s) PROFILE=1 ;;
n) ITERATIONS=$OPTARG ;;
p) PRECMD="$OPTARG" ;;
c) COMMAND="$OPTARG" ;;
@ -43,12 +44,17 @@ echo "First run."
sh -c "$PRECMD"
sh -c "$COMMAND"
if [ "$PROFILE" ]; then profile stop || true; fi
for n in `seq 1 $ITERATIONS`
do echo -n "$n"
sh -c "$PRECMD >/dev/null 2>&1"
echo -n "."
sync
PROF=$LOGFILE.p.$n
if [ "$PROFILE" ]; then profile start --rtc -o $PROF -f 3; fi
time -C sh -c "$COMMAND >/dev/null 2>&1; sync" 2>>$LOGFILE
if [ "$PROFILE" ]; then profile stop; sprofalyze -d $PROF >$PROF.d; fi
echo -n " "
done
echo "Done."