1#! /bin/sh
2#
3# Collects multiple outputs of x11perf.  Just feed it a list of files, each
4# containing the output from an x11perf run, and this shell will extract the
5# object/second information and show it in tabular form.  An 80-column line
6# is big enough to compare 4 different servers.
7#
8# This script normally uses the results from $1 to extract the test label
9# descriptions, so you can run x11perf on a subset of the test and then
10# compare the results.  But note that x11perffill requires the labels file
11# to be a superset of the x11perf results file.  If you run into an ugly
12# situation in which none of the servers completes the desired tests
13# (quite possible on non-DEC servers :), you can use -l <filename> as $1 and
14# $2 to force x11perfcomp to use the labels stored in file $2.  (You can run
15# x11perf with the -labels option to generate such a file.)
16#
17# Mark Moraes, University of Toronto <moraes@csri.toronto.edu>
18# Joel McCormack, DEC Western Research Lab <joel@decwrl.dec.com>
19#
20
21PATH="@x11perfcompdir@:/bin:/usr/bin:$PATH"
22export PATH
23
24MKTEMP="@MKTEMP@"
25
26set -e
27if [ "x$MKTEMP" != "x" ] && [ -x "$MKTEMP" ] ; then
28    tmp=`$MKTEMP -p /tmp -d rates.XXXXXX`
29    if [ "x$tmp" = "x" ]; then exit 1 ; fi
30else
31    tmp=${TMPDIR-/tmp}/rates.$$
32    mkdir $tmp || exit 1
33fi
34trap "rm -rf $tmp" 0 1 2 15
35mkdir $tmp/rates
36ratio=
37allfiles=
38# Include relative rates in output?  Report only relative rates?
39case $1 in
40-r|-a)
41	ratio=1
42	shift;
43	;;
44-ro)
45	ratio=2
46	shift;
47	;;
48esac
49# Get either the provided label file, or construct one from all the
50# files given.
51case $1 in
52-l)	cp $2 $tmp/labels
53	shift; shift
54	;;
55*)	for file in "$@"; do
56		awk '$2 == "reps" || $2 == "trep" { print $0; next; }' $file |
57		sed 's/^.*: //' |
58		sed 's/ /_/g' |
59		awk 'NR > 1 	{ printf ("%s %s\n", prev, $0); } \
60				{ prev = $0; }'
61	done | tsort 2>/dev/null | sed 's/_/ /g' > $tmp/labels
62	;;
63esac
64# Go through all files, and create a corresponding rate file for each
65n=1
66for i
67do
68# Get lines with average numbers, fill in any tests that may be missing
69# then extract the rate field
70	base=`basename $i`
71	(echo "     $n  "
72	 echo '--------'
73	 awk '$2 == "reps" || $2 == "trep" { \
74		line = $0; \
75		next; \
76	    } \
77	    NF == 0 && line != "" { \
78		print line; \
79		line=""; \
80		next; \
81	    } \
82	 ' $i > $tmp/$n.avg
83	 fillblnk $tmp/$n.avg $tmp/labels |
84	 sed 's/( *\([0-9]*\)/(\1/'   |
85	 awk '$2 == "reps" || $2 == "trep" { \
86						n = substr($6,2,length($6)-7); \
87						printf "%8s\n", n; \
88					   }'
89	) > $tmp/rates/$n
90	echo "$n: $i"
91	allfiles="$allfiles$tmp/rates/$n "
92	n=`expr $n + 1`
93done
94case x$ratio in
95x)
96	ratio=/bin/cat
97	;;
98x1)
99	ratio="perfboth $n"
100	;;
101*)
102	ratio="perfratio $n"
103	;;
104esac
105echo ''
106(echo Operation; echo '---------'; cat $tmp/labels) |
107paste $allfiles - | sed 's/	/  /g' | $ratio
108rm -rf $tmp
109