mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-01-06 01:30:19 +01:00
The perf tree's sha1 is now in the cache file name, so that if the performance suite itself ever changes then new data will be generated rather than using stale stuff from the cache. Also, we now use the src tree's sha1 rather than the commit's so that commits that don't change the src directory are also treated as identical, (which they really should be as far as performance of the library itself is concerned).
116 lines
3.1 KiB
Bash
Executable file
116 lines
3.1 KiB
Bash
Executable file
#!/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
|
|
echo " $argv0 <revision>" >&2
|
|
echo " $argv0 <rev1> <rev2>" >&2
|
|
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
|
|
echo "The performance results are cached in .perf next to the .git directory." >&2
|
|
exit 1
|
|
}
|
|
|
|
if [ $# -eq 1 ]; then
|
|
old="$1^"
|
|
new="$1"
|
|
elif [ $# -eq 2 ]; then
|
|
old="$1"
|
|
new="$2"
|
|
else
|
|
usage
|
|
fi
|
|
|
|
git_setup() {
|
|
SUBDIRECTORY_OK='Yes'
|
|
. git-sh-setup
|
|
CAIRO_DIR=$(dirname $GIT_DIR)
|
|
if [ "$CAIRO_DIR" = "." ]; then
|
|
CAIRO_DIR=$(pwd)
|
|
fi
|
|
CAIRO_PERF_DIR=$CAIRO_DIR/.perf
|
|
}
|
|
|
|
rev2sha() {
|
|
rev=$1
|
|
git rev-parse --verify $rev || ( echo "Cannot resolve $rev as a git object" && exit 1 )
|
|
}
|
|
|
|
# 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.
|
|
rev2perf() {
|
|
rev=$1
|
|
src_tree_sha=$(rev2sha $rev:src)
|
|
perf_tree_sha=$(rev2sha HEAD:perf)
|
|
echo "$CAIRO_PERF_DIR/${perf_tree_sha}-${src_tree_sha}.perf"
|
|
}
|
|
|
|
# Usage: run_cairo_perf_if_not_cached <rev>
|
|
run_cairo_perf_if_not_cached() {
|
|
rev=$1
|
|
|
|
owd=$(pwd)
|
|
sha=$(rev2sha $rev)
|
|
perf=$(rev2perf $rev)
|
|
if [ -e $perf ]; then
|
|
return 0
|
|
fi
|
|
if [ ! -d $CAIRO_PERF_DIR ]; then
|
|
echo "Creating new perf cache in $CAIRO_PERF_DIR"
|
|
mkdir $CAIRO_PERF_DIR
|
|
fi
|
|
cd $CAIRO_PERF_DIR
|
|
|
|
if [ ! -d build ]; then
|
|
git clone -s $CAIRO_DIR build
|
|
(cd build; git checkout -b tmp-cairo-perf-diff $sha; CFLAGS="-O2" ./autogen.sh)
|
|
fi
|
|
cd build
|
|
|
|
git checkout tmp-cairo-perf-diff
|
|
git reset --hard $sha
|
|
make CFLAGS="-O2" || (rm config.cache && make CFLAGS="-O2")
|
|
cp -a $CAIRO_DIR/boilerplate .
|
|
(cd boilerplate; make)
|
|
cp -a $CAIRO_DIR/perf .
|
|
cd perf;
|
|
make || exit 1
|
|
(make perf || echo "*** Performance test crashed") > $perf
|
|
cd $owd
|
|
}
|
|
|
|
if [ ! -e $old ]; then
|
|
git_setup
|
|
run_cairo_perf_if_not_cached $old
|
|
old=$(rev2perf $old)
|
|
fi
|
|
|
|
if [ ! -e $new ]; then
|
|
git_setup
|
|
run_cairo_perf_if_not_cached $new
|
|
new=$(rev2perf $new)
|
|
fi
|
|
|
|
cairo-perf-diff-files $old $new
|