Skip to content

Commit 12b6dc7

Browse files
committed
TerminalWriter: write "collecting" msg only once every 0.1s
Running `pytest -k doesnotmatch` on pytest's own tests takes ~3s with Kitty terminal for me, but only ~1s with `-q`. It also is faster with urxvt, but still takes 2.2s there. This patch only calls `report_collect` every 0.1s, which is good enough for reporting collection progress, and improves the time with both Kitty and urxvt to ~1.2s for me.
1 parent 2a45851 commit 12b6dc7

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/_pytest/terminal.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ def __init__(self, config, file=None):
248248
self.isatty = file.isatty()
249249
self._progress_nodeids_reported = set()
250250
self._show_progress_info = self._determine_show_progress_info()
251+
self._collect_report_last_write = 0
251252

252253
def _determine_show_progress_info(self):
253254
"""Return True if we should display progress information based on the current config"""
@@ -486,6 +487,12 @@ def pytest_collectreport(self, report):
486487
self._numcollected += len(items)
487488
if self.isatty:
488489
# self.write_fspath_result(report.nodeid, 'E')
490+
491+
t = time.time()
492+
if self._collect_report_last_write > t - 0.1:
493+
return
494+
self._collect_report_last_write = t
495+
489496
self.report_collect()
490497

491498
def report_collect(self, final=False):

0 commit comments

Comments
 (0)