Merge tag 'samba-4.6.8' into v4-6-test
[Samba.git] / script / show_test_time
blob81bb7932a4a8d90d6bc853a6ee92a194597dffa5
1 #!/usr/bin/python
3 import optparse
4 import os.path
5 import subprocess
6 import sys
8 parser = optparse.OptionParser()
9 parser.add_option("--limit", dest="limit", type=int,
10 help="Limit to this number of output entries.", default=0)
11 (opts, args) = parser.parse_args()
13 third_party_path = os.path.join(os.path.dirname(sys.argv[0]), "..", "lib")
15 durations = {}
17 cmd = "subunit-1to2 | subunit-ls --times --no-passthrough"
19 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stdin=sys.stdin, shell=True)
20 for l in p.stdout:
21 l = l.strip()
22 (name, duration) = l.rsplit(" ", 1)
23 durations[name] = float(duration)
25 if opts.limit:
26 print "Top %d tests by run time:" % opts.limit
28 for i, (name, length) in enumerate(sorted(
29 durations.items(), cmp=lambda (k1,v1), (k2, v2): cmp(v1, v2), reverse=True)):
30 if opts.limit and i == opts.limit:
31 break
32 print "%d: %s -> %ds" % (i+1, name, length)