Timing `gc.collect()`: Quantifying Explicit Collection Overhead

Measuring the execution time of `gc.collect()` using `time.perf_counter()` or `timeit` directly reveals the performance impact and pause times caused by explicit or automatic full garbage collection cycles.

Sources

Open the full topic