blob: 6e5808a01152a6ca1f93011b3f15a8590a561975 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#!/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";
}
|