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()
14 cmd
= "subunit-1to2 | subunit-ls --times --no-passthrough"
16 p
= subprocess
.Popen(cmd
, stdout
=subprocess
.PIPE
, stdin
=sys
.stdin
, shell
=True)
19 (name
, duration
) = l
.rsplit(" ", 1)
20 durations
[name
] = float(duration
)
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
:
29 print("%d: %s -> %ds" % (i
+1, name
, length
))