script: Add a script to display testsuite runtime sorted
authorMatthieu Patou <mat@matws.net>
Wed, 2 Jan 2013 04:56:16 +0000 (20:56 -0800)
committerMatthieu Patou <mat@samba.org>
Wed, 9 Jan 2013 06:19:54 +0000 (07:19 +0100)
Signed-off-by: Matthieu Patou <mat@matws.net>
Reviewed-By: Andrew Bartlett <abartlet@samba.org>
script/show_testsuite_time [new file with mode: 0755]

diff --git a/script/show_testsuite_time b/script/show_testsuite_time
new file mode 100755 (executable)
index 0000000..4015321
--- /dev/null
@@ -0,0 +1,40 @@
+#!/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;
+if ($#ARGV >= 0) {
+       open($fh, "<", $ARGV[0]) || die "can't open ".$ARGV[0];
+} else {
+       $fh = $in;
+}
+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{$a}<=>$hash{$b} } keys(%hash);
+for my $l (@sorted) {
+       print $l."\n";
+}