diff options
-rwxr-xr-x | utils/parse_testcodec.pl | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/utils/parse_testcodec.pl b/utils/parse_testcodec.pl new file mode 100755 index 0000000000..c31b54ebd0 --- /dev/null +++ b/utils/parse_testcodec.pl | |||
@@ -0,0 +1,121 @@ | |||
1 | #!/usr/bin/perl | ||
2 | |||
3 | #parse test codec output files and give wiki formatted results. | ||
4 | |||
5 | |||
6 | if(scalar(@ARGV) != 2 && scalar(@ARGV) != 1){ | ||
7 | print "Usage: parser_testcodec.pl new_results old_results (compares two results)\n". | ||
8 | " parser_testcodec.pl new_results (formats just one result)\n"; | ||
9 | } | ||
10 | |||
11 | my %newfile; | ||
12 | |||
13 | #open new benchmark file | ||
14 | open FILE, $ARGV[0]; | ||
15 | while ($line = <FILE>){ | ||
16 | chomp $line; | ||
17 | $filename=$line; | ||
18 | #print $filename."\n"; | ||
19 | |||
20 | $line = <FILE>; | ||
21 | $line = <FILE>; | ||
22 | $line =~ m/-\s([0-9\.]*)s/; | ||
23 | $decodetime = $1; | ||
24 | |||
25 | $line = <FILE>; | ||
26 | $line = <FILE>; | ||
27 | $line =~ m/([0-9\.]*)\%/; | ||
28 | $realtime = $1; | ||
29 | |||
30 | $line = <FILE>; | ||
31 | $line =~ m/([0-9\.]*)MHz/; | ||
32 | $mhz=$1; | ||
33 | #consume blank line | ||
34 | $line = <FILE>; | ||
35 | |||
36 | #store in hash | ||
37 | $newfile{$filename} = [$realtime, $mhz, $decodetime]; | ||
38 | |||
39 | #| flac_5.flac | 175906 of 175906 | Decode time - 27.74s | File duration - 175.90s | 634.10% realtime | 12.61MHz | | ||
40 | #print "| $filename | Decode time - $decodetime"."s | $realtime"."% realtime | $mhz"."MHz |\n"; | ||
41 | #print "$filename\t$realtime\t$mhz\n"; | ||
42 | |||
43 | |||
44 | } | ||
45 | |||
46 | #open old benchmark file | ||
47 | my %oldfile; | ||
48 | open FILE, $ARGV[1]; | ||
49 | while ($line = <FILE>){ | ||
50 | chomp $line; | ||
51 | $filename=$line; | ||
52 | #print $filename."\n"; | ||
53 | |||
54 | $line = <FILE>; | ||
55 | $line = <FILE>; | ||
56 | $line =~ m/-\s([0-9\.]*)s/; | ||
57 | $decodetime = $1; | ||
58 | |||
59 | $line = <FILE>; | ||
60 | $line = <FILE>; | ||
61 | $line =~ m/([0-9\.]*)\%/; | ||
62 | $realtime = $1; | ||
63 | |||
64 | $line = <FILE>; | ||
65 | $line =~ m/([0-9\.]*)MHz/; | ||
66 | $mhz=$1; | ||
67 | |||
68 | #consume blank line | ||
69 | $line = <FILE>; | ||
70 | |||
71 | #store in hash | ||
72 | $oldfile{$filename} = [$realtime, $mhz, $decodetime]; | ||
73 | |||
74 | |||
75 | |||
76 | } | ||
77 | |||
78 | my @keylist; | ||
79 | |||
80 | @keylist = sort {$a cmp $b} keys(%newfile); | ||
81 | #print for wiki | ||
82 | my $oldkey = "nothing_"; | ||
83 | foreach $key (@keylist){ | ||
84 | |||
85 | #check if this is a new format and add the table heading | ||
86 | $oldkey =~ m/([a-z1-9]*)/; | ||
87 | |||
88 | if(!($key =~ m/$1_/i)){ | ||
89 | print "| *MP3* |||||\n" if($key =~ m/lame/); | ||
90 | print "| *AAC-LC* |||||\n" if($key =~ m/nero/); | ||
91 | print "| *Vorbis* |||||\n" if($key =~ m/vorbis/); | ||
92 | print "| *WMA Standard* |||||\n" if($key =~ m/wma_/); | ||
93 | print "| *WAVPACK* |||||\n" if($key =~ m/wv/); | ||
94 | print "| *Nero AAC-HE* |||||\n" if($key =~ m/aache/); | ||
95 | print "| *Apple Lossless* |||||\n" if($key =~ m/applelossless/); | ||
96 | print "| *Monkeys Audio* |||||\n" if($key =~ m/ape/); | ||
97 | print "| *Musepack* |||||\n" if($key =~ m/mpc/); | ||
98 | print "| *FLAC* |||||\n" if($key =~ m/flac/); | ||
99 | print "| *Cook (RA)* |||||\n" if($key =~ m/cook/); | ||
100 | print "| *AC3 (A52)* |||||\n" if($key =~ m/a52/); | ||
101 | print "| *atrac3* |||||\n" if($key =~ m/atrac3/); | ||
102 | print "| *True Audio* |||||\n" if($key =~ m/true/); | ||
103 | print "| *MP2* |||||\n" if($key =~ m/toolame/); | ||
104 | #potiential future rockbox codecs | ||
105 | print "| *atrac* |||||\n" if($key =~ m/atrac1/); | ||
106 | print "| *WMA Professional* |||||\n" if($key =~ m/wmapro/); | ||
107 | print "| *WMA Lossless* |||||\n" if($key =~ m/wmal/); | ||
108 | |||
109 | } | ||
110 | |||
111 | if(defined($oldfile{$key})){ | ||
112 | $str=sprintf("%1.2f",($oldfile{$key}->[1]-$newfile{$key}->[1])/$oldfile{$key}->[1]*100+100 ); | ||
113 | print "| $key | $newfile{$key}->[0]"."% realtime | Decode time - $newfile{$key}->[2]s | ".sprintf("%2.2f",$newfile{$key}->[1])."MHz | ".$str."%|\n"; | ||
114 | }elsif(scalar(@ARGV) ==2){ | ||
115 | print "| $key | $newfile{$key}->[0]"."% realtime | Decode time - $newfile{$key}->[2]s | $newfile{$key}->[1]"."MHz | - |\n"; | ||
116 | } else{ | ||
117 | |||
118 | print "| $key | ". $newfile{$key}->[0]."% realtime | Decode time - $newfile{$key}->[2]s | ".sprintf("%2.2f",$newfile{$key}->[1])."MHz |\n"; | ||
119 | } | ||
120 | $oldkey=$key; | ||
121 | } \ No newline at end of file | ||