wb_sids2xids: split out wb_sids2xids_next_sids2unix()
[Samba.git] / script / show_test_time
blob5a84f19787c3dfa56f11301a90cd3e8355ea3c8b
1 #!/usr/bin/python
2 from __future__ import print_function
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 durations = {}
15 cmd = "subunit-1to2 | subunit-ls --times --no-passthrough"
17 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stdin=sys.stdin, shell=True)
18 for l in p.stdout:
19 l = l.strip()
20 (name, duration) = l.rsplit(" ", 1)
21 durations[name] = float(duration)
23 if opts.limit:
24 print("Top %d tests by run time:" % opts.limit)
26 for i, (name, length) in enumerate(sorted(
27 durations.items(), key=lambda x: x[1], reverse=True)):
28 if opts.limit and i == opts.limit:
29 break
30 print("%d: %s -> %ds" % (i+1, name, length))