Skip to content

Instantly share code, notes, and snippets.

@nbraud
Created April 30, 2019 17:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nbraud/caf2c7a37d74d3ae83bbe402a723f2cd to your computer and use it in GitHub Desktop.
Save nbraud/caf2c7a37d74d3ae83bbe402a723f2cd to your computer and use it in GitHub Desktop.
PPB: Reveal which cycles are created (and collected) on each frame
diff --git i/ppb/engine.py w/ppb/engine.py
index 4300133..bc25616 100644
--- i/ppb/engine.py
+++ w/ppb/engine.py
@@ -101,6 +101,7 @@ class GameEngine(Engine, EventMixin, LoggingMixin):
def main_loop(self, collect_statistics: True) -> 'pandas.DataFrame': pass
def main_loop(self, collect_statistics=False):
+ collect_statistics = False
if collect_statistics:
import numpy as np
import pandas as pd
@@ -111,6 +112,7 @@ class GameEngine(Engine, EventMixin, LoggingMixin):
for column in columns:
stats[column] = stats[column].astype(float)
+ gc.set_debug(gc.DEBUG_SAVEALL)
with gc_disabled():
for frame_count in count():
if not self.running:
@@ -129,8 +131,11 @@ class GameEngine(Engine, EventMixin, LoggingMixin):
self.manage_scene()
scene_end = time.monotonic()
- gc_unreachable = gc.collect() if frame_count % 100 == 99 else 0
+ gc_unreachable = gc.collect()
gc_end = time.monotonic()
+ if gc.garbage:
+ print(gc.garbage)
+ gc.garbage.clear()
if collect_statistics:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment