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: https://github.com/nodejs/node/pull/65980
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
This commit is contained in:
Filip Skokan committed 2026-09-13 14:01:13 +02:00
1 parent 8ab3c4d807
commit b3e7a60a80
1 file changed
+6 -5
+6 -5
View File
@@ -741,10 +741,11 @@ def RunProcess(context, timeout, args, **rest):
timed_out = True
else:
exit_code = process.poll()
time.sleep(sleep_time)
sleep_time = sleep_time * SLEEP_TIME_FACTOR
if sleep_time > MAX_SLEEP_TIME:
sleep_time = MAX_SLEEP_TIME
if exit_code is None:
time.sleep(sleep_time)
sleep_time = sleep_time * SLEEP_TIME_FACTOR
if sleep_time > MAX_SLEEP_TIME:
sleep_time = MAX_SLEEP_TIME
return (process, exit_code, timed_out)
@@ -1849,7 +1850,7 @@ def Main():
print()
sys.stderr.write("--- Total time: %s ---\n" % FormatTime(duration))
timed_tests = [ t for t in cases_to_run if not t.duration is None ]
timed_tests.sort(key=lambda x: x.duration)
timed_tests.sort(key=lambda x: x.duration, reverse=True)
for i, entry in enumerate(timed_tests[:20], start=1):
t = FormatTimedelta(entry.duration)
sys.stderr.write("%4i (%s) %s\n" % (i, t, entry.GetLabel()))