This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Mar 7th, 2010  |  syntax: Perl  |  size: 3.20 KB  |  views: 276  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.  
  2. #parse test codec output files and give wiki formatted results.  
  3.  
  4.  
  5. if(scalar(@ARGV) != 2 && scalar(@ARGV) != 1){
  6.         print "Ussage: parser_testcodec.pl new_results old_results\n        parser_testcodec.pl new_results\n";  
  7. }
  8.  
  9. my %newfile;
  10.  
  11. #open new benchmark file
  12. open FILE, $ARGV[0];
  13. while ($line = <FILE>){
  14.         chomp $line;
  15.         $filename=$line;
  16.         #print $filename."\n";
  17.        
  18.         $line = <FILE>;
  19.         $line = <FILE>;
  20.         $line =~ m/-\s([0-9\.]*)s/;
  21.         $decodetime = $1;
  22.        
  23.         $line = <FILE>;
  24.         $line = <FILE>;
  25.         $line =~ m/([0-9\.]*)\%/;
  26.         $realtime = $1;
  27.        
  28.         $line = <FILE>;
  29.         $line =~ m/([0-9\.]*)MHz/;
  30.         $mhz=$1;
  31.         #consume blank line
  32.         $line = <FILE>;
  33.        
  34.         #store in hash
  35.         $newfile{$filename} = [$realtime, $mhz, $decodetime];
  36.        
  37.         #| flac_5.flac | 175906 of 175906 | Decode time - 27.74s | File duration - 175.90s | 634.10% realtime | 12.61MHz |
  38.         #print "| $filename | Decode time - $decodetime"."s | $realtime"."% realtime | $mhz"."MHz |\n";
  39.         #print "$filename\t$realtime\n";
  40.  
  41.        
  42. }      
  43.  
  44. #open old benchmark file
  45. my %oldfile;
  46. open FILE, $ARGV[1];
  47. while ($line = <FILE>){
  48.         chomp $line;
  49.         $filename=$line;
  50.         #print $filename."\n";
  51.        
  52.         $line = <FILE>;
  53.         $line = <FILE>;
  54.         $line =~ m/-\s([0-9\.]*)s/;
  55.         $decodetime = $1;
  56.        
  57.         $line = <FILE>;
  58.         $line = <FILE>;
  59.         $line =~ m/([0-9\.]*)\%/;
  60.         $realtime = $1;
  61.        
  62.         $line = <FILE>;
  63.         $line =~ m/([0-9\.]*)MHz/;
  64.         $mhz=$1;
  65.                
  66.         #consume blank line
  67.         $line = <FILE>;
  68.        
  69.         #store in hash
  70.         $oldfile{$filename} = [$realtime, $mhz, $decodetime];
  71.        
  72.  
  73.        
  74. }
  75.  
  76. my @keylist;
  77.  
  78. @keylist = sort {$a cmp  $b}  keys(%newfile);
  79. #print for wiki
  80. my $oldkey = "nothing_";
  81. foreach $key (@keylist){
  82.        
  83.         #check if this is a new format and add the table heading
  84.         $oldkey =~ m/([a-z]*)\_/;
  85.        
  86.        
  87.         if(!($key =~ m/$1/i)){
  88.                 print "| *MP3*  |||||\n" if($key =~ m/lame/);
  89.                 print "| *AAC-LC*  |||||\n" if($key =~ m/nero/);
  90.                 print "| *Vorbis*  |||||\n" if($key =~ m/vorbis/);
  91.                 print "| *WMA Standard*  |||||\n" if($key =~ m/wma/);
  92.                 print "| *WAVPACK*  |||||\n" if($key =~ m/wv/);
  93.                 print "| *Nero AAC-HE*  |||||\n" if($key =~ m/aache/);
  94.                 print "| *Apple Lossless*  |||||\n" if($key =~ m/applelossless/);
  95.                 print "| *Monkey's Audio*  |||||\n" if($key =~ m/ape/);
  96.                 print "| *Musepack*  |||||\n" if($key =~ m/mpc/);
  97.                 print "| *FLAC*  |||||\n" if($key =~ m/flac/);
  98.                 print "| *Cook (RA)*  |||||\n" if($key =~ m/cook/);
  99.                 print "| *AC3 (A52)*  |||||\n" if($key =~ m/a52/);
  100.                 print "| *atrac3*  |||||\n" if($key =~ m/atrac3/);
  101.                 #potiential future rockbox codecs
  102.                 print "| *atrac*  |||||\n" if($key =~ m/atrac1/);
  103.                 print "| *WMA Professional*  |||||\n" if($key =~ m/wmapro/);
  104.                 print "| *WMA Lossless*  |||||\n" if($key =~ m/wmal/);
  105.                
  106.         }
  107.        
  108.         if(defined($oldfile{$key})){
  109.                 $str=sprintf("%1.2f",($oldfile{$key}->[1]-$newfile{$key}->[1])/$oldfile{$key}->[1]*100+100      );
  110.                 print "| $key | $newfile{$key}->[0]"."% realtime | Decode time - $newfile{$key}->[2]s | $newfile{$key}->[1]"."MHz | ".$str."%|\n";
  111.         }elsif(scalar(@ARGV) ==2){
  112.                 print "| $key | $newfile{$key}->[0]"."% realtime | Decode time - $newfile{$key}->[2]s | $newfile{$key}->[1]"."MHz | - |\n";
  113.         } else{
  114.                
  115.                 print "| $key |". $newfile{$key}->[0]."% realtime | Decode time - $newfile{$key}->[2]s | $newfile{$key}->[1]"."MHz |\n";
  116.         }
  117.         $oldkey=$key;
  118. }
clone this paste RAW Paste Data