mdssvc: fix returning file modification date for older Mac releases
[Samba.git] / script / show_test_time
blob70d29d72b5c45eb0dd93e0a7f2f1b0250b913443
1 #!/usr/bin/python
2 import optparse
3 import os.path
4 import subprocess
5 import sys
7 parser = optparse.OptionParser()
8 parser.add_option("--limit", dest="limit", type=int,
9 help="Limit to this number of output entries.", default=0)
10 (opts, args) = parser.parse_args()
12 durations = {}
14 cmd = "subunit-1to2 | subunit-ls --times --no-passthrough"
16 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stdin=sys.stdin, shell=True)
17 for l in p.stdout:
18 l = l.strip()
19 (name, duration) = l.rsplit(" ", 1)
20 durations[name] = float(duration)
22 if opts.limit:
23 print("Top %d tests by run time:" % opts.limit)
25 for i, (name, length) in enumerate(sorted(
26 durations.items(), key=lambda x: x[1], reverse=True)):
27 if opts.limit and i == opts.limit:
28 break
29 print("%d: %s -> %ds" % (i+1, name, length))