Skip to content

Commit b3e7a60

Browse files
committed
tools: reduce test runner timing overhead
RunProcess sleeps after polling even when the child has already exited. Skip that sleep, saving up to 100 ms per test. Sort --time results in descending order to display the 20 slowest tests. Signed-off-by: Filip Skokan <panva.ip@gmail.com> Assisted-by: Codex PR-URL: #65980 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: LiviaMedeiros <livia@cirno.name>
1 parent 8ab3c4d commit b3e7a60

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

tools/test.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -741,10 +741,11 @@ def RunProcess(context, timeout, args, **rest):
741741
timed_out = True
742742
else:
743743
exit_code = process.poll()
744-
time.sleep(sleep_time)
745-
sleep_time = sleep_time * SLEEP_TIME_FACTOR
746-
if sleep_time > MAX_SLEEP_TIME:
747-
sleep_time = MAX_SLEEP_TIME
744+
if exit_code is None:
745+
time.sleep(sleep_time)
746+
sleep_time = sleep_time * SLEEP_TIME_FACTOR
747+
if sleep_time > MAX_SLEEP_TIME:
748+
sleep_time = MAX_SLEEP_TIME
748749
return (process, exit_code, timed_out)
749750

750751

@@ -1849,7 +1850,7 @@ def should_keep(case):
18491850
print()
18501851
sys.stderr.write("--- Total time: %s ---\n" % FormatTime(duration))
18511852
timed_tests = [ t for t in cases_to_run if not t.duration is None ]
1852-
timed_tests.sort(key=lambda x: x.duration)
1853+
timed_tests.sort(key=lambda x: x.duration, reverse=True)
18531854
for i, entry in enumerate(timed_tests[:20], start=1):
18541855
t = FormatTimedelta(entry.duration)
18551856
sys.stderr.write("%4i (%s) %s\n" % (i, t, entry.GetLabel()))

0 commit comments

Comments
 (0)