2006-10-25 17:15:22 -07:00
|
|
|
#!/bin/sh
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
|
|
usage() {
|
|
|
|
|
argv0=$(basename $0)
|
|
|
|
|
echo "Usage:" >&2
|
|
|
|
|
echo "For comparing files created my cairo-perf:" >&2
|
|
|
|
|
echo "" >&2
|
|
|
|
|
echo " $argv0 old.perf new.perf" >&2
|
|
|
|
|
echo "" >&2
|
|
|
|
|
echo "For comparing (cached) performance of revisions:" >&2
|
|
|
|
|
echo "" >&2
|
2006-11-10 10:04:01 -08:00
|
|
|
echo " $argv0 [-f] <revision> [-- cairo-perf options]" >&2
|
|
|
|
|
echo " $argv0 [-f] <rev1> <rev2> [-- cairo-perf-options]" >&2
|
2006-10-25 17:15:22 -07:00
|
|
|
echo "" >&2
|
|
|
|
|
echo "If given a single revision, compares its results to that of its" >&2
|
|
|
|
|
echo "(first-parent) predecessor. Otherwise compares the two given revisions." >&2
|
|
|
|
|
echo "The revisions can be any revision accepted by git. For example:" >&2
|
|
|
|
|
echo "" >&2
|
|
|
|
|
echo " $argv0 HEAD # Show impact of latest commit" >&2
|
|
|
|
|
echo " $argv0 1.2.0 1.2.4 # Compare performance of 1.2.0 to 1.2.4" >&2
|
|
|
|
|
echo "" >&2
|
2006-11-10 10:04:01 -08:00
|
|
|
echo "The -f option forces cairo-perf-diff to re-run performance tests even" >&2
|
|
|
|
|
echo "if cached performance data is available." >&2
|
|
|
|
|
echo "" >&2
|
|
|
|
|
echo "Additional options can be passed the child cairo-perf process" >&2
|
|
|
|
|
echo "by separating them with a double hyphen (--). For example, to" >&2
|
|
|
|
|
echo "examine what the impact of the latest change is on the stroke" >&2
|
|
|
|
|
echo "test you might use:" >&2
|
|
|
|
|
echo "" >&2
|
|
|
|
|
echo " $argv0 HEAD -- stroke" >&2
|
|
|
|
|
echo "" >&2
|
2006-10-25 17:15:22 -07:00
|
|
|
echo "The performance results are cached in .perf next to the .git directory." >&2
|
2007-01-04 15:06:48 +00:00
|
|
|
echo "" >&2
|
|
|
|
|
echo "Set CAIRO_AUTOGEN_OPTIONS to pass options to autogen for both" >&2
|
|
|
|
|
echo "builds." >&2
|
2006-10-25 17:15:22 -07:00
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-10 10:04:01 -08:00
|
|
|
# Yes, this ugly ad-hoc option parsing could be cleaned up
|
|
|
|
|
if [ $# -eq 0 ] || [ "$1" = "--" ]; then
|
|
|
|
|
usage
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ "$1" = "-f" ]; then
|
|
|
|
|
force_cairo_perf="true"
|
|
|
|
|
shift 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ $# -eq 1 ] || [ "$2" = "--" ]; then
|
2006-10-25 17:15:22 -07:00
|
|
|
old="$1^"
|
|
|
|
|
new="$1"
|
2006-11-10 10:04:01 -08:00
|
|
|
shift 1
|
|
|
|
|
else
|
2006-10-25 17:15:22 -07:00
|
|
|
old="$1"
|
|
|
|
|
new="$2"
|
2006-11-10 10:04:01 -08:00
|
|
|
shift 2
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
CAIRO_PERF_OPTIONS="-r -i 10"
|
|
|
|
|
if [ $# -gt 0 ]; then
|
|
|
|
|
if [ "$1" = "--" ]; then
|
|
|
|
|
shift 1
|
|
|
|
|
CAIRO_PERF_OPTIONS="$CAIRO_PERF_OPTIONS $@"
|
|
|
|
|
else
|
|
|
|
|
usage
|
|
|
|
|
fi
|
2006-10-25 17:15:22 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
git_setup() {
|
|
|
|
|
SUBDIRECTORY_OK='Yes'
|
|
|
|
|
. git-sh-setup
|
|
|
|
|
CAIRO_DIR=$(dirname $GIT_DIR)
|
2006-11-03 12:40:09 -08:00
|
|
|
if [ "$CAIRO_DIR" = "." ]; then
|
|
|
|
|
CAIRO_DIR=$(pwd)
|
|
|
|
|
fi
|
2006-10-25 17:15:22 -07:00
|
|
|
CAIRO_PERF_DIR=$CAIRO_DIR/.perf
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rev2sha() {
|
|
|
|
|
rev=$1
|
2006-11-03 15:32:57 -08:00
|
|
|
git rev-parse --verify $rev || ( echo "Cannot resolve $rev as a git object" && exit 1 )
|
2006-10-25 17:15:22 -07:00
|
|
|
}
|
|
|
|
|
|
2007-03-14 21:18:09 +01:00
|
|
|
cpu_count() {
|
|
|
|
|
test -f /proc/cpuinfo &&
|
|
|
|
|
grep -c '^processor[[:blank:]]\+:' /proc/cpuinfo ||
|
|
|
|
|
echo 1
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-03 15:32:57 -08:00
|
|
|
# We cache performance output based on a two-part name capturing the
|
|
|
|
|
# current performance test suite and the library being tested. We
|
|
|
|
|
# capture these as the tree object of the perf directory in HEAD and
|
|
|
|
|
# the tree object of the src directory of the revision being tested.
|
|
|
|
|
#
|
|
|
|
|
# This way, whenever the performance suite is updated, cached output
|
|
|
|
|
# from old versions of the suite are automatically invalidated. Also,
|
|
|
|
|
# if a commit just changes things outside of the src tree, (say it
|
|
|
|
|
# changes the "test" test suite, or README or configure.in, or
|
|
|
|
|
# whatever), cairo-perf-diff will be smart enough to still use cached
|
|
|
|
|
# results from a run with an equivalent src tree.
|
2006-10-25 17:15:22 -07:00
|
|
|
rev2perf() {
|
|
|
|
|
rev=$1
|
2006-11-03 15:32:57 -08:00
|
|
|
src_tree_sha=$(rev2sha $rev:src)
|
|
|
|
|
perf_tree_sha=$(rev2sha HEAD:perf)
|
|
|
|
|
echo "$CAIRO_PERF_DIR/${perf_tree_sha}-${src_tree_sha}.perf"
|
2006-10-25 17:15:22 -07:00
|
|
|
}
|
|
|
|
|
|
2006-11-10 10:20:49 -08:00
|
|
|
# Usage: run_cairo_perf_if_not_cached <rev> <suffix>
|
|
|
|
|
# The <rev> argument must be a valid git ref-spec that can
|
|
|
|
|
# be resolved to a commit. The suffix is just something
|
|
|
|
|
# unique so that build directories can be separated for
|
|
|
|
|
# multiple calls to this function.
|
2006-10-25 17:15:22 -07:00
|
|
|
run_cairo_perf_if_not_cached() {
|
|
|
|
|
rev=$1
|
2006-11-10 10:20:49 -08:00
|
|
|
build_dir="build-$2"
|
2006-10-25 17:15:22 -07:00
|
|
|
|
|
|
|
|
owd=$(pwd)
|
|
|
|
|
sha=$(rev2sha $rev)
|
|
|
|
|
perf=$(rev2perf $rev)
|
2006-11-10 10:04:01 -08:00
|
|
|
if [ -e $perf ] && [ "$force_cairo_perf" != "true" ]; then
|
2006-10-25 17:15:22 -07:00
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
if [ ! -d $CAIRO_PERF_DIR ]; then
|
|
|
|
|
echo "Creating new perf cache in $CAIRO_PERF_DIR"
|
|
|
|
|
mkdir $CAIRO_PERF_DIR
|
|
|
|
|
fi
|
2006-11-13 14:44:07 -08:00
|
|
|
|
2006-11-14 13:27:52 -08:00
|
|
|
cd $CAIRO_DIR
|
2006-11-13 14:44:07 -08:00
|
|
|
boilerplate_files=$(git ls-tree --name-only HEAD boilerplate/*)
|
|
|
|
|
perf_files=$(git ls-tree --name-only HEAD perf/*)
|
2006-10-25 17:15:22 -07:00
|
|
|
cd $CAIRO_PERF_DIR
|
|
|
|
|
|
2006-11-10 10:20:49 -08:00
|
|
|
if [ ! -d $build_dir ]; then
|
|
|
|
|
git clone -s $CAIRO_DIR $build_dir
|
2006-11-13 14:44:07 -08:00
|
|
|
(cd $build_dir; git checkout -b tmp-cairo-perf-diff $sha)
|
2006-10-25 17:15:22 -07:00
|
|
|
fi
|
2006-11-10 10:20:49 -08:00
|
|
|
cd $build_dir
|
2006-10-25 17:15:22 -07:00
|
|
|
|
2006-10-27 00:51:24 -07:00
|
|
|
git checkout tmp-cairo-perf-diff
|
|
|
|
|
git reset --hard $sha
|
2007-03-14 21:18:09 +01:00
|
|
|
|
|
|
|
|
if [ -z "$MAKEFLAGS" ]; then
|
|
|
|
|
export MAKEFLAGS="-j$(expr $(cpu_count) + 1)"
|
|
|
|
|
fi
|
|
|
|
|
|
2006-11-13 14:44:07 -08:00
|
|
|
if [ ! -e Makefile ]; then
|
2007-01-04 15:06:48 +00:00
|
|
|
CFLAGS="-O2" ./autogen.sh $CAIRO_AUTOGEN_OPTIONS
|
2006-11-13 14:44:07 -08:00
|
|
|
fi
|
2006-10-25 17:15:22 -07:00
|
|
|
make CFLAGS="-O2" || (rm config.cache && make CFLAGS="-O2")
|
2006-11-13 14:44:07 -08:00
|
|
|
for file in $boilerplate_files; do
|
|
|
|
|
rsync $CAIRO_DIR/$file boilerplate
|
|
|
|
|
done
|
2006-11-03 13:26:48 -08:00
|
|
|
(cd boilerplate; make)
|
2006-11-13 14:44:07 -08:00
|
|
|
for file in $perf_files; do
|
|
|
|
|
rsync $CAIRO_DIR/$file perf
|
|
|
|
|
done
|
2006-11-03 13:26:48 -08:00
|
|
|
cd perf;
|
|
|
|
|
make || exit 1
|
2006-11-10 10:04:01 -08:00
|
|
|
echo "Running \"cairo-perf $CAIRO_PERF_OPTIONS\" against $rev. Results will be cached in:"
|
|
|
|
|
echo "$perf"
|
|
|
|
|
(./cairo-perf $CAIRO_PERF_OPTIONS || echo "*** Performance test crashed") >> $perf
|
2006-10-25 17:15:22 -07:00
|
|
|
cd $owd
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if [ ! -e $old ]; then
|
|
|
|
|
git_setup
|
2006-11-10 10:20:49 -08:00
|
|
|
run_cairo_perf_if_not_cached $old old
|
2006-10-25 17:15:22 -07:00
|
|
|
old=$(rev2perf $old)
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ ! -e $new ]; then
|
|
|
|
|
git_setup
|
2006-11-10 10:20:49 -08:00
|
|
|
run_cairo_perf_if_not_cached $new new
|
2006-10-25 17:15:22 -07:00
|
|
|
new=$(rev2perf $new)
|
|
|
|
|
fi
|
|
|
|
|
|
2006-11-10 10:04:01 -08:00
|
|
|
$CAIRO_DIR/perf/cairo-perf-diff-files $old $new
|