OLD | NEW |
1 #!/usr/bin/perl | 1 #!/usr/bin/perl |
2 | 2 |
3 # Copyright (C) 2006 Apple Computer, Inc. All rights reserved. | 3 # Copyright (C) 2006 Apple Computer, Inc. All rights reserved. |
4 # | 4 # |
5 # Redistribution and use in source and binary forms, with or without | 5 # Redistribution and use in source and binary forms, with or without |
6 # modification, are permitted provided that the following conditions | 6 # modification, are permitted provided that the following conditions |
7 # are met: | 7 # are met: |
8 # | 8 # |
9 # 1. Redistributions of source code must retain the above copyright | 9 # 1. Redistributions of source code must retain the above copyright |
10 # notice, this list of conditions and the following disclaimer. | 10 # notice, this list of conditions and the following disclaimer. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 61 |
62 my $gainOrLoss = $newAverage <= $oldAverage ? "GAIN" : "LOSS"; | 62 my $gainOrLoss = $newAverage <= $oldAverage ? "GAIN" : "LOSS"; |
63 my $difference = abs($newAverage - $oldAverage); | 63 my $difference = abs($newAverage - $oldAverage); |
64 my $differencePercent = $difference / $oldAverage * 100; | 64 my $differencePercent = $difference / $oldAverage * 100; |
65 printf("\nperformance %s of %.2f%% (%.1f / %.1f)\n", $gainOrLoss, $differencePer
cent, $difference, $oldAverage); | 65 printf("\nperformance %s of %.2f%% (%.1f / %.1f)\n", $gainOrLoss, $differencePer
cent, $difference, $oldAverage); |
66 print "\n"; | 66 print "\n"; |
67 | 67 |
68 sub parseResults | 68 sub parseResults |
69 { | 69 { |
70 my ($file) = @_; | 70 my ($file) = @_; |
71 | 71 |
72 open(FILE, $file) or die "Couldn't open file: $file"; | 72 open(FILE, $file) or die "Couldn't open file: $file"; |
73 my @results = <FILE>; | 73 my @results = <FILE>; |
74 close(FILE); | 74 close(FILE); |
75 | 75 |
76 @results = sort(@results); | 76 @results = sort(@results); |
77 my $total = 0; | 77 my $total = 0; |
78 for (my $i = 0; $i < $count; $i++) { | 78 for (my $i = 0; $i < $count; $i++) { |
79 $results[$i] =~ s/\D*//; # cut out non-digits | 79 $results[$i] =~ s/\D*//; # cut out non-digits |
80 $total += $results[$i]; | 80 $total += $results[$i]; |
81 } | 81 } |
82 my $average = $total / $count; | 82 my $average = $total / $count; |
83 my $range = $results[$count - 1] - $results[0]; | 83 my $range = $results[$count - 1] - $results[0]; |
84 my $rangePercent = $range / $results[$count - 1] * 100; | 84 my $rangePercent = $range / $results[$count - 1] * 100; |
85 | 85 |
86 return ($average, $range, $rangePercent); | 86 return ($average, $range, $rangePercent); |
87 } | 87 } |
88 | 88 |
OLD | NEW |