#!/usr/bin/perl

{
  my $line;
  $iocount = 0;
  $filecount = 0;
  while($line = <STDIN>)
  {
    while($line =~ /^name,/)
    {
      $line = <STDIN>;
    }
    process($line);
  }
  printIOData();

  printFileData();
}

sub IOHeader
{
  my $version = '1.03';
print "Version  $version      ------Sequential Output------ --Sequential Input- --Random-\n";
print "                    -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--\n";
print "Machine        Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP  /sec %CP\n";
}

sub FileHeader
{
print "                    ------Sequential Create------ --------Random Create--------\n";
print "                    -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--\n";
print "files:max:min        /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP\n";
}

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

  chop($line);
  my $name = $line;
  $name =~ s/,.*$//;
  $line =~ s/$name,//;

# $ioline contains the file-IO data, IE we strip off the data on file creation
  my $ioline = $line;
  $ioline =~ s/,[:0-9\-\+.\/]+,[0-9\+.]+,[0-9\+.]+,[0-9\+.]+,[0-9\+.]+,[0-9\+.]+,[0-9\+.]+,[0-9\+.]+,[0-9\+.]+,[0-9\+.]+,[0-9\+.]+,[0-9\+.]+,[0-9\+.]+$//;
  $ioline =~ s/,,,,,,,,,,,,,$//;
  if(join('', split(/,/,$ioline)) != "")
  {
    $io[$iocount] = $name . "," . $ioline;
    $iocount++;
  }
# $fileline contains the file creation data - everything but $ioline
  my $fileline = substr($line, length($ioline));
  if(join('', split(/,/,$fileline)) != "")
  {
    $file[$filecount] = $name . $fileline;
    $filecount++;
  }
}

sub printFileData
{
  if($filecount < 1){ return; }
  FileHeader();
  for($i = 0; $i < $filecount; $i++)
  {
    @arr = split(/,/,$file[$i]);
    my $size = $arr[1];
    $size =~ s/:0:0:/\//;
    my $desc = $arr[0] . "                   ";
    $desc = substr($desc, 0, 18 - length($size) );
    $desc .= " " . $size;
    printf(STDOUT "%19s %5s %3s %5s %3s %5s %3s %5s %3s %5s %3s %5s %3s\n"
         , $desc, $arr[2], $arr[3], $arr[4], $arr[5], $arr[6], $arr[7]
         , $arr[8], $arr[9], $arr[10], $arr[11], $arr[12], $arr[13]
         , $arr[14], $arr[15]);
  }
}

sub printIOData
{
  if($iocount < 1){ return; }
  IOHeader();
  for($i = 0; $i < $iocount; $i++)
  {
    @arr = split(/,/,$io[$i]);
    my $size = $arr[1];
    my $desc = $arr[0] . "                   ";
    $desc = substr($desc, 0, 18 - length($size) );
    $desc .= " " . $size;
    printf(STDOUT "%19s %5s %3s %5s %3s %5s %3s %5s %3s %5s %3s %5s %3s\n"
         , $desc, $arr[2], $arr[3], $arr[4], $arr[5], $arr[6], $arr[7]
         , $arr[8], $arr[9], $arr[10], $arr[11], $arr[12], $arr[13]
         , $arr[14], $arr[15]);
  }
}

