]> git.saurik.com Git - apple/xnu.git/blob - tools/tests/libMicro/multiview.sh
xnu-3248.60.10.tar.gz
[apple/xnu.git] / tools / tests / libMicro / multiview.sh
1 #!/bin/sh
2 #
3 # CDDL HEADER START
4 #
5 # The contents of this file are subject to the terms
6 # of the Common Development and Distribution License
7 # (the "License"). You may not use this file except
8 # in compliance with the License.
9 #
10 # You can obtain a copy of the license at
11 # src/OPENSOLARIS.LICENSE
12 # or http://www.opensolaris.org/os/licensing.
13 # See the License for the specific language governing
14 # permissions and limitations under the License.
15 #
16 # When distributing Covered Code, include this CDDL
17 # HEADER in each file and include the License file at
18 # usr/src/OPENSOLARIS.LICENSE. If applicable,
19 # add the following below this CDDL HEADER, with the
20 # fields enclosed by brackets "[]" replaced with your
21 # own identifying information: Portions Copyright [yyyy]
22 # [name of copyright owner]
23 #
24 # CDDL HEADER END
25 #
26
27 #
28 # Copyright 2005 Sun Microsystems, Inc. All rights reserved.
29 # Use is subject to license terms.
30 #
31
32 #
33 # output html comparison of several libmicro output data files
34 # usage: multiview file1 file2 file3 file4 ...
35 #
36 # relative ranking is calculated using first as reference
37 # color interpolation is done to indicate relative performance;
38 # the redder the color, the slower the result, the greener the
39 # faster
40
41 awk ' BEGIN {
42 benchmark_count = 0;
43 header_count = 0;
44 }
45 /^#/ {
46 next;
47 }
48 /errors/ {
49 next;
50 }
51 /^\!/ {
52 split($0, A_header, ":");
53 name = substr(A_header[1],2);
54 headers[name]=name;
55 header_data[name,FILENAME] = substr($0, length(name) + 3);
56 if (header_names[name] == 0) {
57 header_names[name] = ++header_count;
58 headers[header_count] = name;
59 }
60 next;
61 }
62
63 {
64 if(NF >= 7) {
65 if (benchmark_names[$1] == 0) {
66 benchmark_names[$1] = ++benchmark_count;
67 benchmarks[benchmark_count] = $1;
68 }
69 if ($6 == 0)
70 benchmark_data[$1,FILENAME] = $4;
71 else
72 benchmark_data[$1,FILENAME] = -1;
73 }
74 }
75
76 END {
77 printf("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n");
78 printf("\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n");
79 printf("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n");
80 printf("<head>\n");
81 printf("<meta http-equiv=\"content-type\" content=\"text/html; charset=ISO-8859-1\" />\n");
82 printf("<meta name=\"author\" content=\"autogen\" />\n");
83 printf("<title>multiview comparison</title>\n")
84 printf("<style type=\"text/css\">\n");
85 printf("body { font-family: sans-serif; }\n");
86 printf("table { border-collapse: collapse; }\n");
87 printf("td { padding: 0.1em; border: 1px solid #ccc; text-align: right; }\n");
88 printf("td.header { text-align: left; }\n");
89 printf("pre { margin-top: 0em; margin-bottom: 0em; }\n");
90 printf("</style>\n");
91 printf("</head>\n");
92 printf("<body bgcolor=\"#ffffff\" link=\"#0000ee\" vlink=\"#cc0000\" alink=\"#0000ee\">\n");
93 printf("<table border=\"1\" cellspacing=\"1\">\n");
94 printf("<tbody>\n");
95 for(i = 1; i <= header_count; i++) {
96 hname = headers[i];
97 printf("<tr><td class=\"header\">%s</td>\n", hname);
98
99 for (j = 1; j < ARGC; j++) {
100 sub("^[\t ]+", "", header_data[hname, ARGV[j]]);
101 printf("<td class=\"header\">%s</td>\n", header_data[hname, ARGV[j]]);
102 }
103 printf("</tr>\n");
104 }
105 printf("<tr>\n");
106 printf("<th>BENCHMARK</th>\n");
107 printf("<th align=\"right\">USECS</th>\n");
108
109 for (i = 2; i < ARGC; i++)
110 printf("<th align=\"right\">USECS [percentage]</th>\n");
111
112 printf("</tr>\n");
113 for(i = 1; i < benchmark_count; i++) {
114 for(j = 1; j < benchmark_count; j++) {
115 if (benchmarks[j] > benchmarks[j + 1]) {
116 tmp = benchmarks[j];
117 benchmarks[j] = benchmarks[j+1];
118 benchmarks[j+1] = tmp;
119 }
120 }
121 }
122
123 for(i = 1; i <= benchmark_count; i++) {
124 name = benchmarks[i];
125 a = benchmark_data[name, ARGV[1]];
126
127 printf("<tr>\n");
128 printf("<td>%s</td>\n", name);
129 if (a > 0)
130 printf("<td><pre>%f</pre></td>\n", a);
131 else {
132 if (a < 0)
133 printf("<td bgcolor=\"#ff0000\">%s</td>\n", "ERRORS");
134 else
135 printf("<td>%s</td>\n", "missing");
136
137 for (j = 2; j < ARGC; j++)
138 printf("<td>%s</td>\n", "not computed");
139 continue;
140 }
141
142 for (j = 2; j < ARGC; j++) {
143 b = benchmark_data[name, ARGV[j]];
144 if (b > 0) {
145 factor = b/a;
146 bgcolor = colormap(factor);
147 if (factor > 1)
148 percentage = -(factor * 100 - 100);
149 if (factor <= 1)
150 percentage = 100/factor - 100;
151
152 printf("<td bgcolor=\"%s\"><pre>%11.5f[%#+7.1f%%]</pre></td>\n",
153 bgcolor, b, percentage);
154 }
155
156 else if (b < 0)
157 printf("<td bgcolor=\"#ff0000\">%s</td>\n", "ERRORS");
158 else
159 printf("<td>%25s</td>\n", "missing");
160
161 }
162 printf("</tr>\n");
163
164 }
165 printf("</tbody></table></body></html>\n");
166
167 }
168
169 function colormap(value, bgcolor, r, g, b)
170 {
171 if (value <= .2)
172 value = .2;
173 if (value > 5)
174 value = 5;
175
176 if (value < .9) {
177 r = colorcalc(.2, value, .9, 0, 255);
178 g = colorcalc(.2, value, .9, 153, 255);
179 b = colorcalc(.2, value, .9, 0, 255);
180 bgcolor=sprintf("#%2.2x%2.2x%2.2x", r, g, b);
181 }
182 else if (value < 1.1)
183 bgcolor="#ffffff";
184 else {
185 r = 255;
186 g = colorcalc(1.1, value, 5, 255, 0);
187 b = colorcalc(1.1, value, 5, 255, 0);
188 bgcolor=sprintf("#%2.2x%2.2x%2.2x", r, g, b);
189 }
190
191 return (bgcolor);
192 }
193
194 function colorcalc(min, value, max, mincolor, maxcolor)
195 {
196 return((value - min)/(max-min) * (maxcolor-mincolor) + mincolor);
197 }
198
199 ' "$@"
200
201