dtneededsize: +-r
[massrebuild.git] / dtneededsize
index 1caeb10..6603bde 100755 (executable)
@@ -4,6 +4,8 @@ use warnings;
 use File::Basename qw(&dirname);
 use File::Find;
 use Data::Dumper;
 use File::Basename qw(&dirname);
 use File::Find;
 use Data::Dumper;
+use Statistics::Basic::StdDev;
+use List::Util;
 
 $|=1;
 sub readfile {
 
 $|=1;
 sub readfile {
@@ -16,6 +18,14 @@ sub readfile {
   return $r;
 }
 
   return $r;
 }
 
+my %R;
+if (($ARGV[0]||"") eq "-r") {
+  shift;
+  my $r=readfile shift;
+  $R{$1}=1 while $r=~s/^(.*?)\n//;
+  die $r if $r;
+}
+
 my %D;
 # ==> build/Cadence-1.0.0-0.12.20200504git5787908.fc33.src.rpm.dtneeded <==
 # /usr/lib/debug/.dwz/Cadence isdwzcommon 479079 NA
 my %D;
 # ==> build/Cadence-1.0.0-0.12.20200504git5787908.fc33.src.rpm.dtneeded <==
 # /usr/lib/debug/.dwz/Cadence isdwzcommon 479079 NA
@@ -24,6 +34,7 @@ my %D;
 # ==> build/CVector-1.0.3.1-21.fc33.src.rpm.dtneeded <==
 # /usr/lib64/libCVector-1.0.3.so.2.0.0 nodwzcommon 28088 28896
 for my $dtneededfn (glob "build/*.dtneeded") {
 # ==> build/CVector-1.0.3.1-21.fc33.src.rpm.dtneeded <==
 # /usr/lib64/libCVector-1.0.3.so.2.0.0 nodwzcommon 28088 28896
 for my $dtneededfn (glob "build/*.dtneeded") {
+  next if %R && !$R{($dtneededfn=~m{^build/(.*?)-[^-]*-[^-]*$})[0]."-debuginfo"};
   local *F;
   open F,$dtneededfn or die "$dtneededfn: $1";
   local $_;
   local *F;
   open F,$dtneededfn or die "$dtneededfn: $1";
   local $_;
@@ -114,6 +125,8 @@ find {
 my $dwzsizeall=0;
 my $dwzsizeduplall=0;
 my $dtsizeall=0;
 my $dwzsizeall=0;
 my $dwzsizeduplall=0;
 my $dtsizeall=0;
+my @ratioall;
+my @ratioduplall;
 my $computed=0;
 BINFN: for my $binfn (@DEBUG) {
 #  warn "$binfn...\n".Dumper([sort @{$F{$binfn}{"needed"}}]);
 my $computed=0;
 BINFN: for my $binfn (@DEBUG) {
 #  warn "$binfn...\n".Dumper([sort @{$F{$binfn}{"needed"}}]);
@@ -190,8 +203,11 @@ warn "$binfn: ".Dumper(\%dwzcommons);
   $dwzsizeall+=$dwzsizetot;
   $dwzsizeduplall+=$dwzsizedupltot;
   $dtsizeall+=$dtsizetot;
   $dwzsizeall+=$dwzsizetot;
   $dwzsizeduplall+=$dwzsizedupltot;
   $dtsizeall+=$dtsizetot;
+  push @ratioall    ,$dwzsizetot    /$dtsizetot;
+  push @ratioduplall,$dwzsizedupltot/$dtsizetot;
 #  warn "$binfn done\n".Dumper([sort keys(%l)]);
 }
 #  warn "$binfn done\n".Dumper([sort keys(%l)]);
 }
-print "dwzsizeall    =$dwzsizeall"    ." dtsizeall=$dtsizeall =".$dwzsizeall    /$dtsizeall."\n";
-print "dwzsizeduplall=$dwzsizeduplall"." dtsizeall=$dtsizeall =".$dwzsizeduplall/$dtsizeall."\n";
+print "dwzsizeall    =$dwzsizeall"    ." dtsizeall=$dtsizeall =".$dwzsizeall    /$dtsizeall." avg=".List::Util::sum(@ratioall    )/@ratioall    ." stddev=".Statistics::Basic::stddev(\@ratioall    )."\n";
+print "dwzsizeduplall=$dwzsizeduplall"." dtsizeall=$dtsizeall =".$dwzsizeduplall/$dtsizeall." avg=".List::Util::sum(@ratioduplall)/@ratioduplall." stddev=".Statistics::Basic::stddev(\@ratioduplall)."\n";
 print "computed=$computed of DEBUG=".(0+@DEBUG)." =".$computed/@DEBUG."\n";
 print "computed=$computed of DEBUG=".(0+@DEBUG)." =".$computed/@DEBUG."\n";
+#print Dumper \@ratioall;