5 ### XXX Source common functions from cairo-perf-diff
13 As opposed to its sibling, cairo-perf-diff, cairo-perf-graph targets
14 reviewing changes between series by graphically comparing the performance
17 The two revisions can be any revision accepted by git. For example:
19 $argv0 1.2.0 1.2.4 # Compare performance of 1.2.0 to 1.2.4
24 Forces cairo-perf-diff to re-run performance tests
25 even if cached performance data is available.
28 With this option performance changes are summarized
31 Additional options can be passed the child cairo-perf process
32 by separating them with a double hyphen (--). For example, to
33 examine what the impact of the latest change is on the stroke
38 The performance results are cached in .perf next to the .git directory.
40 Set CAIRO_AUTOGEN_OPTIONS to pass options to autogen for both
47 # First, pull off any known options
50 -f|--force) force_cairo_perf="true";;
51 -h|--html) html_output="true";;
52 -s|--show) show_only="true";;
59 # Then if anything is left that still looks like an option, (begins
60 # with a dash), give usage to catch --help or any other -garbage
61 if [ $# -eq 0 ] || [ "`echo "$1" | sed 's/^-//'`" != "$1" ]; then
65 # Finally, pick up the actual revision arguments
70 # And post-finally, pass anything after -- on to cairo-perf
71 CAIRO_PERF_OPTIONS="-r -i 25"
73 if [ "$1" = "--" ]; then
75 CAIRO_PERF_OPTIONS="$CAIRO_PERF_OPTIONS $@"
83 . "$(git --exec-path)/git-sh-setup"
84 CAIRO_DIR=`dirname $GIT_DIR`
85 if [ "$CAIRO_DIR" = "." ]; then
88 CAIRO_PERF_DIR=$CAIRO_DIR/.perf
93 git rev-parse --verify $rev || ( echo "Cannot resolve $rev as a git object" && exit 1 )
97 test -f /proc/cpuinfo &&
98 grep -c '^processor[[:blank:]]\+:' /proc/cpuinfo ||
102 # We cache performance output based on a two-part name capturing the
103 # current performance test suite and the library being tested. We
104 # capture these as the tree object of the perf directory in HEAD and
105 # the tree object of the src directory of the revision being tested.
107 # This way, whenever the performance suite is updated, cached output
108 # from old versions of the suite are automatically invalidated. Also,
109 # if a commit just changes things outside of the src tree, (say it
110 # changes the "test" test suite, or README or configure.in, or
111 # whatever), cairo-perf-diff will be smart enough to still use cached
112 # results from a run with an equivalent src tree.
116 src_tree_sha=`rev2sha $rev:src`
117 perf_tree_sha=`rev2sha HEAD:perf`
118 echo "$CAIRO_PERF_DIR/${sha}-${perf_tree_sha}-${src_tree_sha}.perf"
122 src_tree_sha=`rev2sha $rev:src`
123 perf_tree_sha=`rev2sha HEAD:perf`
124 echo "$CAIRO_PERF_DIR/*-${perf_tree_sha}-${src_tree_sha}.perf"
127 # Usage: run_cairo_perf_if_not_cached <rev> <suffix>
128 # The <rev> argument must be a valid git ref-spec that can
129 # be resolved to a commit. The suffix is just something
130 # unique so that build directories can be separated for
131 # multiple calls to this function.
132 run_cairo_perf_if_not_cached() {
139 glob=`rev2perf_glob $rev`
140 if [ -e $glob ] && [ "$force_cairo_perf" != "true" ] || [ -n "$show_only" ]; then
143 if [ ! -d $CAIRO_PERF_DIR ]; then
144 echo "Creating new perf cache in $CAIRO_PERF_DIR"
145 mkdir $CAIRO_PERF_DIR
149 boilerplate_files=`git ls-tree --name-only HEAD boilerplate/*`
150 perf_files=`git ls-tree --name-only HEAD perf/*`
153 if [ ! -d $build_dir ]; then
154 git clone -s $CAIRO_DIR $build_dir
155 (cd $build_dir; git checkout -b tmp-cairo-perf-diff $sha)
159 git checkout tmp-cairo-perf-diff
160 git reset --hard $sha
162 if [ -z "$MAKEFLAGS" ]; then
163 CPU_COUNT=`cpu_count`
164 export MAKEFLAGS="-j`expr $CPU_COUNT + 1`"
167 if [ ! -e Makefile ]; then
168 CFLAGS="-O2" ./autogen.sh $CAIRO_AUTOGEN_OPTIONS
170 make CFLAGS="-O2" || (rm config.cache && make CFLAGS="-O2")
171 for file in $boilerplate_files; do
172 rsync $CAIRO_DIR/$file boilerplate
174 (cd boilerplate; make)
175 for file in $perf_files; do
176 rsync $CAIRO_DIR/$file perf
179 make cairo-perf || exit 1
180 echo "Running \"cairo-perf $CAIRO_PERF_OPTIONS\" against $rev. Results will be cached in:"
182 (./cairo-perf $CAIRO_PERF_OPTIONS || echo "*** Performance test crashed") >> $perf
188 # Build cairo-perf-graph-files if not available
189 if [ ! -e $CAIRO_DIR/perf/cairo-perf-graph-files ]; then
190 echo "Building cairo-perf-graph-files"
191 if [ "x$OS" = "xWindows_NT" ]; then
192 make -f Makefile.win32 -C $CAIRO_DIR/perf/ cairo-perf-graph-files CFG=debug
194 make -C $CAIRO_DIR/perf/ cairo-perf-graph-files
199 for rev in `git rev-list --reverse $old..$new`; do
200 run_cairo_perf_if_not_cached $rev rev
202 [ -e "$perf" ] && revs="$revs $perf"
205 exec $CAIRO_DIR/perf/cairo-perf-graph-files $revs
206 #exec $CAIRO_DIR/libtool --mode=execute gdb --args $CAIRO_DIR/perf/cairo-perf-graph-files $revs