1N/A#!/bin/sh
1N/A#
1N/A# CDDL HEADER START
1N/A#
1N/A# The contents of this file are subject to the terms
1N/A# of the Common Development and Distribution License
1N/A# (the "License"). You may not use this file except
1N/A# in compliance with the License.
1N/A#
1N/A# You can obtain a copy of the license at
1N/A# src/OPENSOLARIS.LICENSE
1N/A# or http://www.opensolaris.org/os/licensing.
1N/A# See the License for the specific language governing
1N/A# permissions and limitations under the License.
1N/A#
1N/A# When distributing Covered Code, include this CDDL
1N/A# HEADER in each file and include the License file at
1N/A# usr/src/OPENSOLARIS.LICENSE. If applicable,
1N/A# add the following below this CDDL HEADER, with the
1N/A# fields enclosed by brackets "[]" replaced with your
1N/A# own identifying information: Portions Copyright [yyyy]
1N/A# [name of copyright owner]
1N/A#
1N/A# CDDL HEADER END
1N/A#
1N/A
1N/A#
1N/A# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
1N/A# Use is subject to license terms.
1N/A#
1N/A
1N/A#
1N/A# output html comparison of several libmicro output data files
1N/A# usage: multiview file1 file2 file3 file4 ...
1N/A#
1N/A# relative ranking is calculated using first as reference
1N/A# color interpolation is done to indicate relative performance;
1N/A# the redder the color, the slower the result, the greener the
1N/A# faster
1N/A
1N/A/bin/nawk ' BEGIN {
1N/A benchmark_count = 0;
1N/A header_count = 0;
1N/A}
1N/A/^#/ {
1N/A continue;
1N/A }
1N/A/errors/ {
1N/A continue;
1N/A }
1N/A/^\!/ {
1N/A split($0, A_header, ":");
1N/A name = substr(A_header[1],2);
1N/A headers[name]=name;
1N/A header_data[name,FILENAME] = substr($0, length(name) + 3);
1N/A if (header_names[name] == 0) {
1N/A header_names[name] = ++header_count;
1N/A headers[header_count] = name;
1N/A }
1N/A continue;
1N/A}
1N/A
1N/A {
1N/A if(NF >= 7) {
1N/A if (benchmark_names[$1] == 0) {
1N/A benchmark_names[$1] = ++benchmark_count;
1N/A benchmarks[benchmark_count] = $1;
1N/A }
1N/A if ($6 == 0)
1N/A benchmark_data[$1,FILENAME] = $4;
1N/A else
1N/A benchmark_data[$1,FILENAME] = -1;
1N/A }
1N/A}
1N/A
1N/AEND {
3N/A printf("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n");
3N/A printf("\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n");
3N/A printf("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n");
1N/A printf("<head>\n");
3N/A printf("<meta http-equiv=\"content-type\" content=\"text/html; charset=ISO-8859-1\" />\n");
3N/A printf("<meta name=\"author\" content=\"autogen\" />\n");
1N/A printf("<title>multiview comparison</title>\n")
3N/A printf("<style type=\"text/css\">\n");
3N/A printf("body { font-family: sans-serif; }\n");
3N/A printf("table { border-collapse: collapse; }\n");
3N/A printf("td { padding: 0.1em; border: 1px solid #ccc; text-align: right; }\n");
3N/A printf("td.header { text-align: left; }\n");
3N/A printf("pre { margin-top: 0em; margin-bottom: 0em; }\n");
3N/A printf("</style>\n");
1N/A printf("</head>\n");
1N/A printf("<body bgcolor=\"#ffffff\" link=\"#0000ee\" vlink=\"#cc0000\" alink=\"#0000ee\">\n");
1N/A printf("<table border=\"1\" cellspacing=\"1\">\n");
1N/A printf("<tbody>\n");
1N/A for(i = 1; i <= header_count; i++) {
1N/A hname = headers[i];
3N/A printf("<tr><td class=\"header\">%s</td>\n", hname);
1N/A
3N/A for (j = 1; j < ARGC; j++) {
3N/A sub("^[\t ]+", "", header_data[hname, ARGV[j]]);
3N/A printf("<td class=\"header\">%s</td>\n", header_data[hname, ARGV[j]]);
1N/A }
3N/A printf("</tr>\n");
1N/A }
1N/A printf("<tr>\n");
3N/A printf("<th>BENCHMARK</th>\n");
3N/A printf("<th align=\"right\">USECS</th>\n");
1N/A
1N/A for (i = 2; i < ARGC; i++)
7N/A printf("<th align=\"right\">USECS [percentage]</th>\n");
1N/A
7N/A printf("</tr>\n");
1N/A for(i = 1; i < benchmark_count; i++) {
1N/A for(j = 1; j < benchmark_count; j++) {
1N/A if (benchmarks[j] > benchmarks[j + 1]) {
1N/A tmp = benchmarks[j];
1N/A benchmarks[j] = benchmarks[j+1];
1N/A benchmarks[j+1] = tmp;
1N/A }
1N/A }
1N/A }
1N/A
1N/A for(i = 1; i <= benchmark_count; i++) {
1N/A name = benchmarks[i];
1N/A a = benchmark_data[name, ARGV[1]];
1N/A
1N/A printf("<tr>\n");
3N/A printf("<td>%s</td>\n", name);
1N/A if (a > 0)
3N/A printf("<td><pre>%f</pre></td>\n", a);
1N/A else {
1N/A if (a < 0)
3N/A printf("<td bgcolor=\"#ff0000\">%s</td>\n", "ERRORS");
1N/A else
3N/A printf("<td>%s</td>\n", "missing");
1N/A
1N/A for (j = 2; j < ARGC; j++)
3N/A printf("<td>%s</td>\n", "not computed");
1N/A continue;
1N/A }
1N/A
1N/A for (j = 2; j < ARGC; j++) {
1N/A b = benchmark_data[name, ARGV[j]];
1N/A if (b > 0) {
1N/A factor = b/a;
1N/A bgcolor = colormap(factor);
1N/A if (factor > 1)
1N/A percentage = -(factor * 100 - 100);
1N/A if (factor <= 1)
1N/A percentage = 100/factor - 100;
1N/A
3N/A printf("<td bgcolor=\"%s\"><pre>%11.5f[%#+7.1f%%]</pre></td>\n",
1N/A bgcolor, b, percentage);
1N/A }
1N/A
1N/A else if (b < 0)
3N/A printf("<td bgcolor=\"#ff0000\">%s</td>\n", "ERRORS");
1N/A else
3N/A printf("<td>%25s</td>\n", "missing");
1N/A
1N/A }
1N/A printf("</tr>\n");
1N/A
1N/A }
3N/A printf("</tbody></table></body></html>\n");
1N/A
1N/A}
1N/A
1N/Afunction colormap(value, bgcolor, r, g, b)
1N/A{
1N/A if (value <= .2)
1N/A value = .2;
1N/A if (value > 5)
1N/A value = 5;
1N/A
1N/A if (value < .9) {
1N/A r = colorcalc(.2, value, .9, 0, 255);
1N/A g = colorcalc(.2, value, .9, 153, 255);
1N/A b = colorcalc(.2, value, .9, 0, 255);
3N/A bgcolor=sprintf("#%2.2x%2.2x%2.2x", r, g, b);
1N/A }
1N/A else if (value < 1.1)
1N/A bgcolor="#ffffff";
1N/A else {
1N/A r = 255;
1N/A g = colorcalc(1.1, value, 5, 255, 0);
1N/A b = colorcalc(1.1, value, 5, 255, 0);
3N/A bgcolor=sprintf("#%2.2x%2.2x%2.2x", r, g, b);
1N/A }
3N/A
1N/A return (bgcolor);
1N/A}
1N/A
1N/Afunction colorcalc(min, value, max, mincolor, maxcolor)
1N/A{
1N/A return((value - min)/(max-min) * (maxcolor-mincolor) + mincolor);
1N/A}
1N/A
1N/A' "$@"
1N/A
1N/A