diff-out (3095:b11f671d6e05) diff-out (7448:ba1a0193c050)
1#!/usr/bin/perl
2# Copyright (c) 2001-2005 The Regents of The University of Michigan
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are
7# met: redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer;

--- 22 unchanged lines hidden (view full) ---

31# This script diffs two SimpleScalar statistics output files.
32#
33
34use Getopt::Std;
35
36#
37# -t thresh sets threshold for ignoring differences (in %)
38# -p sorts differences by % chg (default is alphabetic)
1#!/usr/bin/perl
2# Copyright (c) 2001-2005 The Regents of The University of Michigan
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are
7# met: redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer;

--- 22 unchanged lines hidden (view full) ---

31# This script diffs two SimpleScalar statistics output files.
32#
33
34use Getopt::Std;
35
36#
37# -t thresh sets threshold for ignoring differences (in %)
38# -p sorts differences by % chg (default is alphabetic)
39# -f ignores fetch-loss statistics
40# -d ignores all distributions
41#
42
43getopts('dfn:pt:h');
44
45if ($#ARGV < 1)
46{
47 print "\nError: need two file arguments (<reference> <new>).\n";
48 print " Options: -d = Ignore distributions\n";
39# -d ignores all distributions
40#
41
42getopts('dfn:pt:h');
43
44if ($#ARGV < 1)
45{
46 print "\nError: need two file arguments (<reference> <new>).\n";
47 print " Options: -d = Ignore distributions\n";
49 print " -f = Ignore fetch-loss stats\n";
50 print " -p = Sort errors by percentage\n";
51 print " -h = Diff header info separately from stats\n";
52 print " -n <num> = Print top <num> errors (default 20)\n";
53 print " -t <num> = Error threshold in percent (default 1)\n\n";
54 die -1;
55}
56
57open(REF, "<$ARGV[0]") or die "Error: can't open $ARGV[0].\n";

--- 67 unchanged lines hidden (view full) ---

125 $stathandle = shift;
126
127 $in_dist = undef;
128 $hashref = { }; # initialize hash for values
129
130 while (<$stathandle>)
131 {
132 next if /^\s*$/; # skip blank lines
48 print " -p = Sort errors by percentage\n";
49 print " -h = Diff header info separately from stats\n";
50 print " -n <num> = Print top <num> errors (default 20)\n";
51 print " -t <num> = Error threshold in percent (default 1)\n\n";
52 die -1;
53}
54
55open(REF, "<$ARGV[0]") or die "Error: can't open $ARGV[0].\n";

--- 67 unchanged lines hidden (view full) ---

123 $stathandle = shift;
124
125 $in_dist = undef;
126 $hashref = { }; # initialize hash for values
127
128 while (<$stathandle>)
129 {
130 next if /^\s*$/; # skip blank lines
133 next if /^\*\*Ignore/; # temporary, to make totaling scripts easy for ISCA 03
134 last if /End Simulation Statistics/;
135
136 s/ *#.*//; # strip comments
137
138 if (/^Memory usage: (\d+) KBytes/) {
139 $stat = 'memory usage';
140 $value = $1;
141 }
142 elsif ($in_dist) {
131 last if /End Simulation Statistics/;
132
133 s/ *#.*//; # strip comments
134
135 if (/^Memory usage: (\d+) KBytes/) {
136 $stat = 'memory usage';
137 $value = $1;
138 }
139 elsif ($in_dist) {
143 if ($in_dist =~ /^fetch_loss_counters/) {
144 if (/^fetch_loss_counters_\d+\.end/) {
145 # end line of distribution: clear $in_dist flag
146 $in_dist = undef;
147 next;
148 }
149 else {
150 next if $opt_f;
151
152 ($stat, $value) = /^(\S+)\s+(.*)/;
153 }
140 if (/(.*)\.end_dist/) {
141 # end line of distribution: clear $in_dist flag
142 $in_dist = undef;
143 next;
154 }
144 }
155 else {
156 if (/(.*)\.end_dist/) {
157 # end line of distribution: clear $in_dist flag
158 $in_dist = undef;
159 next;
160 }
161 if ($opt_d) {
162 next; # bail out if we are ignoring dists...
163 }
164 elsif (/(.*)\.(min|max)_value/) {
165 # treat these like normal stats
166 ($stat, $value) = /^(\S+)\s+(.*)/;
167 }
168 else {
169 # this is ugly because labels in the distribution
170 # buckets don't start in column 0 and may include
171 # embedded spaces
172 ($stat, $value) =
173 /^\s*(\S+(?:.*\S)?)\s+(\d+)\s+\d+\.\d+%/;
174 $stat = $in_dist . '::' . $stat;
175 }
145 if ($opt_d) {
146 next; # bail out if we are ignoring dists...
147 } elsif (/(.*)\.(min|max)_value/) {
148 # treat these like normal stats
149 ($stat, $value) = /^(\S+)\s+(.*)/;
150 } else {
151 ($stat, $value) =
152 /^(\S+(?:.*\S)?)\s+(\d+)\s+\d+\.\d+%/;
153 $stat = $in_dist . '::' . $stat;
176 }
177 }
178 else {
179 if (/(.*)\.start_dist/) {
180 # start line of distribution: set $in_dist flag
181 # and save distribution name for future reference
182 $in_dist = $1;
183 $stat = $1;
184 $value = 0;
185 }
154 }
155 }
156 else {
157 if (/(.*)\.start_dist/) {
158 # start line of distribution: set $in_dist flag
159 # and save distribution name for future reference
160 $in_dist = $1;
161 $stat = $1;
162 $value = 0;
163 }
186 elsif (/^(fetch_loss_counters_\d+)\.start/) {
187 # treat fetch loss counters like distribution, sort of
188 $in_dist = $1;
189 $stat = $1;
190 $value = 0;
191 }
192 else {
193 ($stat, $value) = /^(\S+)\s+(.*)/;
194 }
195 }
196
197 $$hashref{$stat} = $value;
198 }
199

--- 149 unchanged lines hidden (view full) ---

349 if (++$num_errs >= $omit_count)
350 {
351 print "[... additional errors omitted ...]\n";
352 last;
353 }
354}
355
356#
164 else {
165 ($stat, $value) = /^(\S+)\s+(.*)/;
166 }
167 }
168
169 $$hashref{$stat} = $value;
170 }
171

--- 149 unchanged lines hidden (view full) ---

321 if (++$num_errs >= $omit_count)
322 {
323 print "[... additional errors omitted ...]\n";
324 last;
325 }
326}
327
328#
357# Report missing stats, but first filter out distribution buckets:
358# these are mostly noise
359
360@missing_stats = grep { !/::(\d+|overflows)?$/ } @missing_stats;
361
329# Report missing stats
330#
362# get count
363$missing_stats = scalar(@missing_stats);
364
365if ($missing_stats)
366{
367 print "\nMissing $missing_stats reference statistics:\n\n";
368 foreach $stat (@missing_stats)
369 {

--- 4 unchanged lines hidden (view full) ---

374}
375
376#
377# Any stats left in newhash are added since the reference file
378#
379
380@added_stats = keys %$newhash;
381
331# get count
332$missing_stats = scalar(@missing_stats);
333
334if ($missing_stats)
335{
336 print "\nMissing $missing_stats reference statistics:\n\n";
337 foreach $stat (@missing_stats)
338 {

--- 4 unchanged lines hidden (view full) ---

343}
344
345#
346# Any stats left in newhash are added since the reference file
347#
348
349@added_stats = keys %$newhash;
350
382# first filter out distribution buckets: mostly noise
383
384@added_stats = grep { !/::(\d+|overflows)?$/ } @added_stats;
385
386# get count
387$added_stats = scalar(@added_stats);
388
389if ($added_stats)
390{
391 print "\nFound $added_stats new statistics:\n\n";
392 foreach $stat (sort @added_stats)
393 {
394# print "\t$stat\n";
395 printf " %-50s ", $stat;
396 print "$$newhash{$stat}\n";
397 }
398}
399
400cleanup();
351# get count
352$added_stats = scalar(@added_stats);
353
354if ($added_stats)
355{
356 print "\nFound $added_stats new statistics:\n\n";
357 foreach $stat (sort @added_stats)
358 {
359# print "\t$stat\n";
360 printf " %-50s ", $stat;
361 print "$$newhash{$stat}\n";
362 }
363}
364
365cleanup();
401# Exit code is 0 if some stats found & no stats error, 1 otherwise
402$status = ($#key_stats >= 0 && $max_err_mag == 0.0) ? 0 : 1;
366# Exit code is 0 if all stats are found (with no extras) & no stats error, 1 otherwise
367$status = ($missing_stats == 0 && $added_stats == 0 && $max_err_mag == 0.0) ? 0 : 1;
403exit $status;
404
405sub cleanup
406{
407 unlink($refheader) if ($refheader);
408 unlink($newheader) if ($newheader);
409}
368exit $status;
369
370sub cleanup
371{
372 unlink($refheader) if ($refheader);
373 unlink($newheader) if ($newheader);
374}