script: Add a script to display testsuite runtime sorted
[sfrench/samba-autobuild/.git] / script / show_testsuite_time
1 #!/usr/bin/env perl
2 use Time::Local ('timegm');
3 my $in = STDIN;
4 use strict;
5
6 my $intest=0;
7 my $name;
8 my $start=0;
9 my $end=0;
10 my %hash;
11 my $fh;
12 if ($#ARGV >= 0) {
13         open($fh, "<", $ARGV[0]) || die "can't open ".$ARGV[0];
14 } else {
15         $fh = $in;
16 }
17 while(<$fh>)
18 {
19         if (m/^testsuite: (.*)/) {
20                 $intest = 1;
21                 $name = $1;
22         }
23         if (m/testsuite-\w+:/) {
24                 $hash{"$name -> ".($end - $start)} = $end - $start;
25                 $intest = 0;
26                 $start = 0;
27         }
28         if (m/^time: (\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)/ && $intest) {
29                 my $ts=timegm($6,$5,$4,$3,$2 - 1,$1 - 1900);
30                 if ($start == 0) {
31                         $start = $ts;
32                 } else {
33                         $end = $ts;
34                 }
35         }
36 }
37 my @sorted = sort { $hash{$a}<=>$hash{$b} } keys(%hash);
38 for my $l (@sorted) {
39         print $l."\n";
40 }