1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00
samba-mirror/script/show_testsuite_time
Jelmer Vernooij b7efc12406 Print number of slow tests from script rather than wscript.
Change-Id: I6eaa0803b95cc81f514a2176f4e06f1e3fff4077
Signed-Off-By: Jelmer Vernooij <jelmer@samba.org>

Reviewed-by: Andrew Bartlett <abartlet@samba.org>

Autobuild-User(master): Jelmer Vernooij <jelmer@samba.org>
Autobuild-Date(master): Mon Nov 24 13:06:46 CET 2014 on sn-devel-104
2014-11-24 13:06:46 +01:00

52 lines
937 B
Perl
Executable File

#!/usr/bin/env perl
use Time::Local ('timegm');
my $in = STDIN;
use strict;
my $intest=0;
my $name;
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: (.*)/) {
$intest = 1;
$name = $1;
}
if (m/testsuite-\w+:/) {
$hash{"$name -> ".($end - $start)} = $end - $start;
$intest = 0;
$start = 0;
}
if (m/^time: (\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)/ && $intest) {
my $ts=timegm($6,$5,$4,$3,$2 - 1,$1 - 1900);
if ($start == 0) {
$start = $ts;
} else {
$end = $ts;
}
}
}
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";
}