diff-out: clean up options
Make diff-out sort stats changes by percentage by default, with '-a' to use current alpha sort (instead of requiring '-p' to sort by percentage). Other minor options cleanup too.
This commit is contained in:
@@ -33,23 +33,17 @@
|
|||||||
|
|
||||||
use Getopt::Std;
|
use Getopt::Std;
|
||||||
|
|
||||||
#
|
getopts('adn:t:h');
|
||||||
# -t thresh sets threshold for ignoring differences (in %)
|
|
||||||
# -p sorts differences by % chg (default is alphabetic)
|
|
||||||
# -d ignores all distributions
|
|
||||||
#
|
|
||||||
|
|
||||||
getopts('dfn:pt:h');
|
|
||||||
|
|
||||||
if ($#ARGV < 1)
|
if ($#ARGV < 1)
|
||||||
{
|
{
|
||||||
print "\nError: need two file arguments (<reference> <new>).\n";
|
print "\nError: need two file arguments (<reference> <new>).\n";
|
||||||
print " Options: -d = Ignore distributions\n";
|
print " Options: -d = Ignore distributions\n";
|
||||||
print " -p = Sort errors by percentage\n";
|
print " -a = Sort errors alphabetically (default: by percentage)\n";
|
||||||
print " -h = Diff header info separately from stats\n";
|
print " -h = Diff header info separately from stats\n";
|
||||||
print " -n <num> = Print top <num> errors (default 20)\n";
|
print " -n <num> = Print top <num> errors (default 20, 0 for all)\n";
|
||||||
print " -t <num> = Error threshold in percent (default 1)\n\n";
|
print " -t <num> = Ignore errors below <num> percent (default 0)\n\n";
|
||||||
die -1;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
open(REF, "<$ARGV[0]") or die "Error: can't open $ARGV[0].\n";
|
open(REF, "<$ARGV[0]") or die "Error: can't open $ARGV[0].\n";
|
||||||
@@ -61,10 +55,10 @@ open(NEW, "<$ARGV[1]") or die "Error: can't open $ARGV[1].\n";
|
|||||||
#
|
#
|
||||||
|
|
||||||
# Ignorable error (in percent)
|
# Ignorable error (in percent)
|
||||||
$err_thresh = ($opt_t) ? $opt_t : 0;
|
$err_thresh = defined($opt_t) ? $opt_t : 0;
|
||||||
|
|
||||||
# Number of stats to print before omitting
|
# Number of stats to print before omitting
|
||||||
$omit_count = ($opt_n) ? $opt_n : 20;
|
$omit_count = defined($opt_n) ? $opt_n : 20;
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -291,16 +285,18 @@ foreach $key_stat (@key_stats)
|
|||||||
$newvalue - $refvalue, pct_diff($refvalue, $newvalue));
|
$newvalue - $refvalue, pct_diff($refvalue, $newvalue));
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\nLargest $omit_count relative errors (> %d%%):\n\n", $err_thresh);
|
printf("\nDifferences > %d%%:\n\n", $err_thresh);
|
||||||
|
|
||||||
$num_errs = 0;
|
if ($opt_a) {
|
||||||
|
# leave stats sorted alphabetically, doesn't make sense to cut them off
|
||||||
if ($opt_p)
|
$omit_count = 0;
|
||||||
{
|
} else {
|
||||||
# sort differences by percent change
|
# sort differences by percent change
|
||||||
@errs = sort { abs($$b[3]) <=> abs($$a[3]) } @errs;
|
@errs = sort { abs($$b[3]) <=> abs($$a[3]) } @errs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$num_errs = 0;
|
||||||
|
|
||||||
foreach $err (@errs)
|
foreach $err (@errs)
|
||||||
{
|
{
|
||||||
($statname, $refvalue, $newvalue, $reldiff) = @$err;
|
($statname, $refvalue, $newvalue, $reldiff) = @$err;
|
||||||
@@ -318,9 +314,9 @@ foreach $err (@errs)
|
|||||||
$statname, $refvalue, $newvalue, $newvalue - $refvalue, $reldiff);
|
$statname, $refvalue, $newvalue, $newvalue - $refvalue, $reldiff);
|
||||||
|
|
||||||
# only print top N errors
|
# only print top N errors
|
||||||
if (++$num_errs >= $omit_count)
|
if ($omit_count > 0 && ++$num_errs >= $omit_count)
|
||||||
{
|
{
|
||||||
print "[... additional errors omitted ...]\n";
|
print "[... showing top $omit_count errors only, additional errors omitted ...]\n";
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user