#!/usr/bin/perl # compareDiff.pl # # Take the output of two runs of randCompareMean.pl and # compare significant differences # # Write the results to standard out - how many significant # differences were interchanged (swapped), lost, kept, or # added. # # This software was produced by NIST, an agency of the U.S. government, # and by statute is not subject to copyright in the United States. Recipients # of this software assume all responsibilities associated with its operation, # modification and maintenance. # Version 1.0 #---------------------------------------------------------------------------- $file1 = $ARGV[0]; $file2 = $ARGV[1]; $runOfInterest = $ARGV[2]; # allows filtering of runs $uniqueCount = $ARGV[3]; # way of making output line unique open FILE1, "$file1" || die "Can't open $file1: $!\n"; open FILE2, "$file2" || die "Can't open $file2: $!\n"; while ($line = ) { #ignore lines other than significant comparisons if ($line =~ />/ && $line =~ /$runOfInterest/) { chomp $line; (undef,undef,undef,undef,undef,$run1,$op,$run2) = split(/\s+/,$line); @runs = sort ($run1,$run2); #print "1 : @runs : $line\n"; $runKeyHash1{"@runs[0] @runs[1]"} = "$run1 $op $run2"; } } close FILE1; while ($line = ) { #ignore lines other than significant comparisons if ($line =~ />/ && $line =~ /$runOfInterest/) { chomp $line; (undef,undef,undef,undef,undef,$run1,$op,$run2) = split(/\s+/,$line); @runs = sort ($run1,$run2); #print "2 : @runs : $line\n"; $runKeyHash2{"@runs[0] @runs[1]"} = "$run1 $op $run2"; } } close FILE2; # File 1 & 2 but change of order foreach $key (sort keys %runKeyHash1) { if (exists $runKeyHash2{$key}) { if ($runKeyHash1{$key} ne $runKeyHash2{$key}) { # Order changed print "1 $runKeyHash1{$key}\n"; print " 2 $runKeyHash2{$key}\n"; $swapped++; } else { # No change in order print "1 2 $runKeyHash1{$key}\n"; $kept++; } delete $runKeyHash1{$key}; delete $runKeyHash2{$key}; } } # File 1 only foreach $key (sort keys %runKeyHash1) { if (!exists $runKeyHash2{$key}) { print "1 - $runKeyHash1{$key}\n"; $lost++ } } # File 2 only foreach $key (sort keys %runKeyHash2) { print "- 2 $runKeyHash2{$key}\n"; $added++; } printf "RESULT: %35s %5d : Swap %5d Lose %5d Keep %5d Add %5d \n",$runOfInterest,$uniqueCount,$swapped,$lost,$kept,$added;