s3: VFS: Remove SMB_VFS_CHMOD_ACL().
[samba.git] / script / show_test_time
index d9a18f034eabd6be688769f6edb07afaf687280a..81bb7932a4a8d90d6bc853a6ee92a194597dffa5 100755 (executable)
@@ -1,19 +1,32 @@
-#!/usr/bin/env perl
-#
-use strict;
-my %h;
-open(FH, "subunit-ls --times --no-passthrough|") || die "pb with subunit-ls";
-while(<FH>)
-{
-       chomp();
-       my @l = split(/ /);
-       my $val = @l[scalar(@l)-1];
-       $h{join(' ',@l)} = $val;
-}
-
-my @sorted = sort { $h{$b}<=>$h{$a} } keys(%h);
-use Data::Dumper;
-foreach my $l (@sorted)
-{
-       print "$l\n";
-}
+#!/usr/bin/python
+
+import optparse
+import os.path
+import subprocess
+import sys
+
+parser = optparse.OptionParser()
+parser.add_option("--limit", dest="limit", type=int,
+                  help="Limit to this number of output entries.", default=0)
+(opts, args) = parser.parse_args()
+
+third_party_path = os.path.join(os.path.dirname(sys.argv[0]), "..", "lib")
+
+durations = {}
+
+cmd = "subunit-1to2 | subunit-ls --times --no-passthrough"
+
+p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stdin=sys.stdin, shell=True)
+for l in p.stdout:
+    l = l.strip()
+    (name, duration) = l.rsplit(" ", 1)
+    durations[name] = float(duration)
+
+if opts.limit:
+    print "Top %d tests by run time:" % opts.limit
+
+for i, (name, length) in enumerate(sorted(
+    durations.items(), cmp=lambda (k1,v1), (k2, v2): cmp(v1, v2), reverse=True)):
+    if opts.limit and i == opts.limit:
+        break
+    print "%d: %s -> %ds" % (i+1, name, length)