Deleted Added
sdiff udiff text old ( 7448:ba1a0193c050 ) new ( 7686:e44757c62695 )
full compact
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;

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

28# Authors: Steve Reinhardt
29
30#
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# -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";
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";
56open(NEW, "<$ARGV[1]") or die "Error: can't open $ARGV[1].\n";
57
58
59#
60# Things that really should be adjustable via the command line
61#
62
63# Ignorable error (in percent)
64$err_thresh = ($opt_t) ? $opt_t : 0;
65
66# Number of stats to print before omitting
67$omit_count = ($opt_n) ? $opt_n : 20;
68
69
70#
71# First copy everything up to the simulation statistics to a pair of
72# temporary files, stripping out date-related items, and do a plain
73# diff. Any differences in the arguments are not necessarily an issue;
74# any differences in the program output should be caught by the EIO
75# mechanism if an EIO file is used.

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

286 $fmt = "%10.${digits}f";
287
288 # print differing values with absolute and relative error
289 printf(" %-30s $fmt $fmt $fmt %+7.2f%%\n",
290 $statname, $refvalue, $newvalue,
291 $newvalue - $refvalue, pct_diff($refvalue, $newvalue));
292}
293
294printf("\nLargest $omit_count relative errors (> %d%%):\n\n", $err_thresh);
295
296$num_errs = 0;
297
298if ($opt_p)
299{
300 # sort differences by percent change
301 @errs = sort { abs($$b[3]) <=> abs($$a[3]) } @errs;
302}
303
304foreach $err (@errs)
305{
306 ($statname, $refvalue, $newvalue, $reldiff) = @$err;
307
308 # deduce format from reference value
309 $pointpos1 = rindex($refvalue, '.');
310 $digits1 = ($pointpos1 < 0) ? 0 :(length($refvalue) - $pointpos1 - 1);
311 $pointpos2 = rindex($newvalue, '.');
312 $digits2 = ($pointpos2 < 0) ? 0 :(length($newvalue) - $pointpos2 - 1);
313 $digits = ($digits1 > $digits2) ? $digits1 : $digits2;
314 $fmt = "%10.${digits}f";
315
316 # print differing values with absolute and relative error
317 printf(" %-30s $fmt $fmt $fmt %+7.2f%%\n",
318 $statname, $refvalue, $newvalue, $newvalue - $refvalue, $reldiff);
319
320 # only print top N errors
321 if (++$num_errs >= $omit_count)
322 {
323 print "[... additional errors omitted ...]\n";
324 last;
325 }
326}
327
328#
329# Report missing stats
330#
331# get count

--- 43 unchanged lines hidden ---