autobuild: Split up the build further with samba-ad-dc-2
[sfrench/samba-autobuild/.git] / script / show_testsuite_time
index 40153218f5f668a343a5ca8609cc3122cb71ddcc..6e5808a01152a6ca1f93011b3f15a8590a561975 100755 (executable)
@@ -9,11 +9,21 @@ my $start=0;
 my $end=0;
 my %hash;
 my $fh;
+my $max=0;
 if ($#ARGV >= 0) {
        open($fh, "<", $ARGV[0]) || die "can't open ".$ARGV[0];
 } else {
        $fh = $in;
 }
+if ($#ARGV >= 1) {
+       $max = $ARGV[1];
+       if ($max =~ /\D/) {
+               die "not a decimal number: '$max'";
+       }
+}
+
+print "TOP $max slowest tests\n";
+
 while(<$fh>)
 {
        if (m/^testsuite: (.*)/) {
@@ -34,7 +44,8 @@ while(<$fh>)
                }
        }
 }
-my @sorted = sort { $hash{$a}<=>$hash{$b} } keys(%hash);
-for my $l (@sorted) {
+my @sorted = sort { $hash{$b}<=>$hash{$a} } keys(%hash);
+$max = @sorted if (($max <= 0) or ($max > @sorted));
+for my $l (@sorted[0..($max - 1)]) {
        print $l."\n";
 }