#!/usr/bin/perl

{
  header();
  my $line;
  while($line = <STDIN>)
  {
    while($line =~ /^name,/)
    {
      $line = <STDIN>;
    }
    process($line);
  }
  footer();
}

sub header
{
  print <<END;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<HTML>
<HEAD><TITLE>Bonnie++ V1.03 Benchmark results</TITLE>
<STYLE type="text/css">
TD.header {text-align: center; backgroundcolor: "#CCFFFF" }
TD.rowheader {text-align: center; backgroundcolor: "#CCCFFF" }
TD.size {text-align: center; backgroundcolor: "#CCCFFF" }
TD.ksec {text-align: center; fontstyle: italic }
</STYLE>
<BODY>
<TABLE ALIGN=center BORDER=3 CELLPADDING=2 CELLSPACING=1>
<TR><TD COLSPAN=2 class="header"></TD>
<TD COLSPAN=6 class="header"><FONT SIZE=+2><B>Sequential Output</B></FONT></TD>
<TD COLSPAN=4 class="header"><FONT SIZE=+2><B>Sequential Input</B></FONT></TD>
<TD COLSPAN=2 ROWSPAN=2 class="header"><FONT SIZE=+2><B>Random<BR>Seeks</B></FONT></TD>
<TD COLSPAN=1 class="header"></TD>
<TD COLSPAN=6 class="header"><FONT SIZE=+2><B>Sequential Create</B></FONT></TD>
<TD COLSPAN=6 class="header"><FONT SIZE=+2><B>Random Create</B></FONT></TD>
</tr>
END
  print "<TR><TD></TD>";
  print "<TD>Size:Chunk Size</TD>";
  heading("Per Char"); heading("Block"); heading("Rewrite");
  heading("Per Char"); heading("Block");
  print "<TD>Num Files</TD>";
  heading("Create"); heading("Read"); heading("Delete");
  heading("Create"); heading("Read"); heading("Delete");
  print "</TR>";

  print "<TR><TD COLSPAN=2></TD>";
  my $i;

  for($i = 0; $i < 5; $i++)
  {
    print '<TD class="ksec"><FONT SIZE=-2>K/sec</FONT></TD>'
        . '<TD class="ksec"><FONT SIZE=-2>% CPU</FONT></TD>';
  }
  print '<TD class="ksec"><FONT SIZE=-2>/ sec</FONT></TD>'
      . '<TD class="ksec"><FONT SIZE=-2>% CPU</FONT></TD>';
  print "<TD></TD>";
  for($i = 0; $i < 6; $i++)
  {
    print '<TD class="ksec"><FONT SIZE=-2>/ sec</FONT></TD>'
        . '<TD class="ksec"><FONT SIZE=-2>% CPU</FONT></TD>';
  }
  print "</TR>\n";
}

sub heading
{
  my($item) = @_;
  print "<TD COLSPAN=2>" . $item . "</TD>";
}

sub footer
{
  print <<END;
</TABLE>
</BODY>
</HTML>
END
}

sub process
{
  my($line) = @_;

  chop($line);
  my $name = $line;
  $name =~ s/,.*$//;
  $line =~ s/$name,//;
  my $size = $line;
  $size =~ s/,.*$//;
  $line =~ s/$size,//;
  print '<TR><TD class="rowheader"><FONT SIZE=+1><B>'
         . $name . "</B></FONT></TD>";
  print '<TD class="size">' . $size . "</TD>";


  $line =~ s/,/<\/TD><TD>/g;
  print "<TD>" . $line . "</TD></TR>\n";
}
