1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00
samba-mirror/script/show_testsuite_time
Matthieu Patou 4055eb6b7d scripts: Allow to specify a limit on the number of tests reported
This allows to report the 10 most slowest for instance.

Change-Id: I987520dbc28f598221c47df314d823f916312aab
Signed-off-by: Matthieu Patou <mat@matws.net>
Reviewed-by: Jelmer Vernooij <jelmer@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-10-17 17:57:04 +02:00

47 lines
837 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];
}
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 unless $max or ($max < $#sorted);
for my $l (@sorted[0..($max - 1)]) {
print $l."\n";
}