| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
erase() clears collected data but also forces the next start() to rerun _init_for_start(), rebuilding Core, Collector, and InOrOut and re-registering atexit/sigterm handlers. For code that repeatedly starts/stops measurement on the same Coverage instance and only needs a clean slate of data between cycles, this reinitialization is pure overhead. clear_data() closes and replaces the current CoverageData, keeping the existing collector/tracer setup intact for the next start(). Closes coveragepy#2139.
clear_data() closed the current CoverageData and made a fresh one, but the closed object stayed referenced in _data_to_close for the life of the process. Over many start/stop/clear cycles (e.g. long fuzzer runs) these closed, empty objects piled up, partly defeating the point of the lighter-weight reset. _close_data() now drops the object from _data_to_close when it forgets it. Also fill in the versionadded placeholder for Coverage.clear_data().
| Back | FazBrowse Home | New Git URL |
Summary
erase() clears collected coverage data, but it also sets things up so
the next start() reruns _init_for_start() — rebuilding Core,
Collector, and InOrOut, and re-registering the atexit/sigterm
handlers. For code that starts/stops measurement on the same
Coverage instance many times in a row and only needs a clean slate
of data between cycles (tracing configuration doesn't change), that
reinitialization is pure overhead.
This adds Coverage.clear_data(): it closes and replaces the current
CoverageData, but leaves the existing collector/tracer setup alone
so the next start() doesn't redo the expensive part.
Closes #2139, which includes a benchmark showing the reinitialization
overhead and the speedup from avoiding it.
Changes
small _close_data() helper it shares the "close and forget the
current CoverageData" logic with.
that repeated cycles behave like the existing erase()-based test,
and that the collector/core/inorout objects from the first start()
are still the ones in use after a clear_data() + start() cycle.
Test plan