Skip to content

Commit eae323f

Browse files
committed
explicitly collect GC
1 parent 1f1ac6a commit eae323f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

benchmarks/bm/_scenario.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import abc
22
import cProfile
33
import dataclasses
4+
import gc
45
import os
56
import time
67
import typing
@@ -87,6 +88,7 @@ def run(self) -> typing.Generator[typing.Callable[[int], None], None, None]:
8788
pass
8889

8990
def _pyperf(self, loops: int) -> float:
91+
gc.collect()
9092
rungen = self.run()
9193
run = next(rungen)
9294
t0 = time.perf_counter()
@@ -97,4 +99,6 @@ def _pyperf(self, loops: int) -> float:
9799
next(rungen)
98100
except StopIteration:
99101
pass
102+
finally:
103+
gc.collect()
100104
return dt

0 commit comments

Comments
 (0)