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 |
36getopts('adn:t:h'); |
37 |
38if ($#ARGV < 1) 39{ 40 print "\nError: need two file arguments (<reference> <new>).\n"; |
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; |
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) |
58$err_thresh = defined($opt_t) ? $opt_t : 0; |
59 60# Number of stats to print before omitting |
61$omit_count = defined($opt_n) ? $opt_n : 20; |
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 |
288printf("\nDifferences > %d%%:\n\n", $err_thresh); |
289 |
290if ($opt_a) { 291 # leave stats sorted alphabetically, doesn't make sense to cut them off 292 $omit_count = 0; 293} else { |
294 # sort differences by percent change 295 @errs = sort { abs($$b[3]) <=> abs($$a[3]) } @errs; 296} 297 |
298$num_errs = 0; 299 |
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 |
317 if ($omit_count > 0 && ++$num_errs >= $omit_count) |
318 { |
319 print "[... showing top $omit_count errors only, additional errors omitted ...]\n"; |
320 last; 321 } 322} 323 324# 325# Report missing stats 326# 327# get count --- 43 unchanged lines hidden --- |