diff-out (7448:ba1a0193c050) | diff-out (7686:e44757c62695) |
---|---|
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 | 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# | 36getopts('adn:t:h'); |
41 | 37 |
42getopts('dfn:pt:h'); 43 | |
44if ($#ARGV < 1) 45{ 46 print "\nError: need two file arguments (<reference> <new>).\n"; | 38if ($#ARGV < 1) 39{ 40 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; | 41 print " Options: -d = Ignore distributions\n"; 42 print " -a = Sort errors alphabetically (default: by percentage)\n"; 43 print " -h = Diff header info separately from stats\n"; 44 print " -n <num> = Print top <num> errors (default 20, 0 for all)\n"; 45 print " -t <num> = Ignore errors below <num> percent (default 0)\n\n"; 46 exit; |
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) | 47} 48 49open(REF, "<$ARGV[0]") or die "Error: can't open $ARGV[0].\n"; 50open(NEW, "<$ARGV[1]") or die "Error: can't open $ARGV[1].\n"; 51 52 53# 54# Things that really should be adjustable via the command line 55# 56 57# Ignorable error (in percent) |
64$err_thresh = ($opt_t) ? $opt_t : 0; | 58$err_thresh = defined($opt_t) ? $opt_t : 0; |
65 66# Number of stats to print before omitting | 59 60# Number of stats to print before omitting |
67$omit_count = ($opt_n) ? $opt_n : 20; | 61$omit_count = defined($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 | 62 63 64# 65# First copy everything up to the simulation statistics to a pair of 66# temporary files, stripping out date-related items, and do a plain 67# diff. Any differences in the arguments are not necessarily an issue; 68# any differences in the program output should be caught by the EIO 69# mechanism if an EIO file is used. --- 210 unchanged lines hidden (view full) --- 280 $fmt = "%10.${digits}f"; 281 282 # print differing values with absolute and relative error 283 printf(" %-30s $fmt $fmt $fmt %+7.2f%%\n", 284 $statname, $refvalue, $newvalue, 285 $newvalue - $refvalue, pct_diff($refvalue, $newvalue)); 286} 287 |
294printf("\nLargest $omit_count relative errors (> %d%%):\n\n", $err_thresh); | 288printf("\nDifferences > %d%%:\n\n", $err_thresh); |
295 | 289 |
296$num_errs = 0; 297 298if ($opt_p) 299{ | 290if ($opt_a) { 291 # leave stats sorted alphabetically, doesn't make sense to cut them off 292 $omit_count = 0; 293} else { |
300 # sort differences by percent change 301 @errs = sort { abs($$b[3]) <=> abs($$a[3]) } @errs; 302} 303 | 294 # sort differences by percent change 295 @errs = sort { abs($$b[3]) <=> abs($$a[3]) } @errs; 296} 297 |
298$num_errs = 0; 299 |
|
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 | 300foreach $err (@errs) 301{ 302 ($statname, $refvalue, $newvalue, $reldiff) = @$err; 303 304 # deduce format from reference value 305 $pointpos1 = rindex($refvalue, '.'); 306 $digits1 = ($pointpos1 < 0) ? 0 :(length($refvalue) - $pointpos1 - 1); 307 $pointpos2 = rindex($newvalue, '.'); 308 $digits2 = ($pointpos2 < 0) ? 0 :(length($newvalue) - $pointpos2 - 1); 309 $digits = ($digits1 > $digits2) ? $digits1 : $digits2; 310 $fmt = "%10.${digits}f"; 311 312 # print differing values with absolute and relative error 313 printf(" %-30s $fmt $fmt $fmt %+7.2f%%\n", 314 $statname, $refvalue, $newvalue, $newvalue - $refvalue, $reldiff); 315 316 # only print top N errors |
321 if (++$num_errs >= $omit_count) | 317 if ($omit_count > 0 && ++$num_errs >= $omit_count) |
322 { | 318 { |
323 print "[... additional errors omitted ...]\n"; | 319 print "[... showing top $omit_count errors only, additional errors omitted ...]\n"; |
324 last; 325 } 326} 327 328# 329# Report missing stats 330# 331# get count --- 43 unchanged lines hidden --- | 320 last; 321 } 322} 323 324# 325# Report missing stats 326# 327# get count --- 43 unchanged lines hidden --- |