1#! /bin/sh
2#
3# $Id: report,v 1.7 2008/02/07 18:11:34 bostic Exp $
4
5# Use our pathname to locate the absolute path for our awk scripts.
6t=`dirname $0`
7h=`(cd $t && echo $PWD)`
8
9# We need a temporary file, and we need to clean it up after failure.
10tmp="$PWD/__t"
11trap 'rm -f $tmp; exit 1' 1 2 3 13 15
12trap 'rm -f $tmp; exit 0' 0
13
14# header --
15#	Output HTML page header.
16#	$1: directory name.
17header()
18{
19	echo "<html>"
20	echo "<head>"
21	machine=`echo $1 | sed 's/.*\.//'`
22	echo "<title>Berkeley DB test_micro run: $machine</title>"
23	echo "</head>"
24	echo "<body bgcolor=white>"
25	echo "<center><h1>Berkeley DB test_micro run: $machine</h1></center>"
26	echo "<p align=right>`date`</p>"
27	test -f UNAME && cat UNAME
28}
29
30# footer --
31#	Output HTML page footer.
32footer()
33{
34	echo "</body>"
35	echo "</html>"
36}
37
38# table --
39#	Create a table.
40#	$1: output file
41table()
42{
43	title="Test $1: `egrep '^#' $1 | sort -u | sed 's/^#[	 ]*//'`"
44	echo "<hr size=1 noshade>"
45	echo "<table cellspacing=0 cellpadding=0 border=0>"
46	echo "<th align=left colspan=2>$title</th>"
47	echo "<tr>"
48	echo "<th align=right>Release</th>"
49	echo "<th align=center>Operations/second</th>"
50	echo "</tr>"
51
52	# You can set the MAJOR and MINOR environment variables to limit
53	# the BDB releases for which a report is created.
54	#
55	# Process the output into a single line per release.
56	egrep "^${MAJOR:-[0-9][0-9]*}.${MINOR:-*}" $1 |
57	awk -f $h/report.awk |
58	sort -n > $tmp
59
60	# Get the release count, and maximum value.
61	nrel=`wc -l $tmp`
62	max=`sort -k 2 -n -t ":" < $tmp | tail -1 | awk -F: '{print $2}'`
63
64	# Display the output.
65	IFS=":"
66	cat $tmp | while true; do
67		# release, average, runs, percent, standard deviation
68		read rel avg runs percent rsd
69		if test "X$rel" = "X" ; then
70			break;
71		fi
72
73		# echo "read: rel $rel, avg $avg, runs $runs, percent $percent, rsd $rsd" > /dev/stderr
74
75		echo "<tr>"
76		echo "<td align=right width=80><pre>$rel</pre></td>"
77		echo "<td>"
78		echo "<table>"
79		echo "<tr>"
80		t=`echo "400 * ($avg/($max + $max/10))" | bc -l`
81		t=`printf %.0f $t`
82		echo "<td bgcolor='#003366' width=$t>&nbsp;</td>"
83		t=`echo "400 - $t" | bc`
84		echo "<td bgcolor='#CCCCCC' width=$t>&nbsp;</td>"
85		echo "<td>&nbsp;&nbsp;</td>"
86		echo "<td align=right width=100><pre>$avg</pre></td>"
87		if test "X$percent" != "X" -o "X$rsd" != "X"; then
88			echo -n "<td align=right><pre>&nbsp;&nbsp;("
89			if test "X$percent" = "X"; then
90				echo -n '***'
91			else
92				echo -n "-$percent"
93			fi
94			if test "X$rsd" != "X"; then
95				echo -n ", $rsd rsd, $runs runs"
96			fi
97			echo ")</pre></td>"
98		fi
99		echo "</tr>"
100		echo "</table>"
101		echo "</tr>"
102	done
103	echo "</table>"
104}
105
106for i in RUN.*; do
107	echo "Building $i..."
108	name=`echo $i | sed 's/RUN.//'`
109	(cd $i
110	header $i
111	for j in `ls [0-9]* | sort -n`; do
112		table $j
113	done
114	footer) > $i/$name.html
115done
116
117exit 0
118