s4:torture:vfs_fruit: smb2/create context AAPL test
[Samba.git] / script / show_testsuite_time
blob6e5808a01152a6ca1f93011b3f15a8590a561975
1 #!/usr/bin/env perl
2 use Time::Local ('timegm');
3 my $in = STDIN;
4 use strict;
6 my $intest=0;
7 my $name;
8 my $start=0;
9 my $end=0;
10 my %hash;
11 my $fh;
12 my $max=0;
13 if ($#ARGV >= 0) {
14 open($fh, "<", $ARGV[0]) || die "can't open ".$ARGV[0];
15 } else {
16 $fh = $in;
18 if ($#ARGV >= 1) {
19 $max = $ARGV[1];
20 if ($max =~ /\D/) {
21 die "not a decimal number: '$max'";
25 print "TOP $max slowest tests\n";
27 while(<$fh>)
29 if (m/^testsuite: (.*)/) {
30 $intest = 1;
31 $name = $1;
33 if (m/testsuite-\w+:/) {
34 $hash{"$name -> ".($end - $start)} = $end - $start;
35 $intest = 0;
36 $start = 0;
38 if (m/^time: (\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)/ && $intest) {
39 my $ts=timegm($6,$5,$4,$3,$2 - 1,$1 - 1900);
40 if ($start == 0) {
41 $start = $ts;
42 } else {
43 $end = $ts;
47 my @sorted = sort { $hash{$b}<=>$hash{$a} } keys(%hash);
48 $max = @sorted if (($max <= 0) or ($max > @sorted));
49 for my $l (@sorted[0..($max - 1)]) {
50 print $l."\n";