"Fossies" - the Fresh Open Source Software Archive

Member "bonnie++-2.00a/bon_csv2txt.in" (26 Dec 2018, 4256 Bytes) of package /linux/privat/bonnie++-2.00a.tgz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/bin/perl
    2 use strict;
    3 
    4 my @io;
    5 my $iocount = 0;
    6 my @file;
    7 my $filecount = 0;
    8 
    9 {
   10   my $line;
   11   while(my $line = <STDIN>)
   12   {
   13     while($line =~ /^name,/)
   14     {
   15       $line = <STDIN>;
   16     }
   17     process($line);
   18   }
   19   printIOData();
   20 
   21   printFileData();
   22 }
   23 
   24 sub IOHeader
   25 {
   26   my $version = '@version@';
   27 printf(STDOUT "Version %9s   ------Sequential Output------ --Sequential Input- --Random-\n", $version);
   28 print "                    -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--\n";
   29 print "Name:Size etc        /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP\n";
   30 }
   31 
   32 sub FileHeader
   33 {
   34 print "                    ------Sequential Create------ --------Random Create--------\n";
   35 print "                    -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--\n";
   36 print "      files:max:min  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP\n";
   37 }
   38 
   39 sub process
   40 {
   41   my($line) = @_;
   42 
   43   chomp($line);
   44   $line =~ s/\r//;
   45   my @arr = split(',', $line);
   46   my $csv_version = '@csv_version@';
   47   if($arr[0] ne $csv_version)
   48   {
   49     printf(STDERR "Expected %s, got %s from %s\n", $csv_version, $arr[0], $line);
   50     return;
   51   }
   52   my $name = $arr[2];
   53 
   54 # merge size and chunk-size
   55   my $tmp = join(':', @arr[5 .. 8]);
   56   $tmp =~ s/:*$//;
   57   $arr[8] = $tmp;
   58 # $ioline contains the file-IO data, IE we strip off the data on file creation
   59   my @ioline = @arr[8 .. 20];
   60   if(join('', @ioline) ne "")
   61   {
   62     $io[$iocount] = $name . "," . join(',', @ioline);
   63     if($#arr > 39)
   64     {
   65       $io[$iocount] .= "," . join(',', @arr[38..43]);
   66     }
   67     $iocount++;
   68   }
   69 
   70 # merge num_files, max_size, min_size, num_dirs, and file_chunk_size
   71   $tmp = $arr[21];
   72   if($arr[22] ne "")
   73   {
   74     $tmp .= ":" . $arr[22];
   75   }
   76   if($arr[23] ne "")
   77   {
   78     $tmp .= ":" . $arr[23];
   79   }
   80   if($arr[24] ne "")
   81   {
   82     $tmp .= "/" . $arr[24];
   83   }
   84   if($arr[25] ne "")
   85   {
   86     $tmp .= ":" . $arr[25];
   87   }
   88   $arr[25] = $tmp;
   89 # $fileline contains the file creation data - everything but $ioline
   90   my @fileline = @arr[25 .. 37];
   91   if(join('', @fileline) ne "")
   92   {
   93     $file[$filecount] = $name . "," . join(',', @fileline);
   94     if($#arr > 43)
   95     {
   96       $file[$filecount] .= "," . join(',', @arr[44..$#arr]);
   97     }
   98     $filecount++;
   99   }
  100 }
  101 
  102 sub printFileData
  103 {
  104   if($filecount < 1){ return; }
  105   FileHeader();
  106   for(my $i = 0; $i < $filecount; $i++)
  107   {
  108     my @arr = split(/,/,$file[$i]);
  109     my $size = $arr[1];
  110     my $desc = $arr[0] . "                   ";
  111     if(length($size) < 18)
  112     {
  113       $desc = substr($desc, 0, 18 - length($size) );
  114       $desc .= " " . $size;
  115     }
  116     else
  117     {
  118       $desc = $size;
  119     }
  120     printf(STDOUT "%19s %5s %3s %5s %3s %5s %3s %5s %3s %5s %3s %5s %3s\n"
  121          , $desc, $arr[2], $arr[3], $arr[4], $arr[5], $arr[6], $arr[7]
  122          , $arr[8], $arr[9], $arr[10], $arr[11], $arr[12], $arr[13]);
  123     if($#arr > 13 && join("", @arr[14..$#arr]) ne "")
  124     {
  125       printf(STDOUT "Latency           %9s %9s %9s %9s %9s %9s\n"
  126            , $arr[14], $arr[15], $arr[16], $arr[17], $arr[18], $arr[19]);
  127     }
  128   }
  129 }
  130 
  131 sub convSpd
  132 {
  133   my ($speed) = @_;
  134   if($speed eq "")
  135   {
  136     return "";
  137   }
  138   if($speed < 10000)
  139   {
  140     return sprintf("%4dk", $speed);
  141   }
  142   if($speed / 1024 < 1000)
  143   {
  144     my $tmp = $speed / 1024;
  145     if($tmp < 100)
  146     {
  147       return sprintf("%4.1fm", $tmp);
  148     }
  149     return sprintf("%4dm", ($tmp + 0.5));
  150   }
  151   return sprintf("%4.1fg", $speed / 1024 / 1024);
  152 }
  153 
  154 sub printIOData
  155 {
  156   if($iocount < 1){ return; }
  157   IOHeader();
  158   for(my $i = 0; $i < $iocount; $i++)
  159   {
  160     my @arr = split(/,/,$io[$i]);
  161     my $size = $arr[1];
  162     my $desc = $arr[0] . "                   ";
  163     if(length($size) < 18)
  164     {
  165       $desc = substr($desc, 0, 18 - length($size) );
  166       $desc .= " " . $size;
  167     }
  168     else
  169     {
  170       $desc = $size;
  171     }
  172     printf(STDOUT "%19s %5s %3s %5s %3s %5s %3s %5s %3s %5s %3s %5s %3s\n"
  173          , $desc, convSpd($arr[2]), $arr[3], convSpd($arr[4]), $arr[5], convSpd($arr[6]), $arr[7]
  174          , convSpd($arr[8]), $arr[9], convSpd($arr[10]), $arr[11], $arr[12], $arr[13]);
  175     if($#arr > 13 && join("", @arr[14..$#arr]) ne "")
  176     {
  177       printf(STDOUT "Latency           %9s %9s %9s %9s %9s %9s\n"
  178            , $arr[14], $arr[15], $arr[16], $arr[17], $arr[18], $arr[19]);
  179     }
  180   }
  181 }
  182