-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: ilan-gold <[email protected]> Co-authored-by: Philipp A. <[email protected]>
- Loading branch information
1 parent
9918044
commit d51f84c
Showing
12 changed files
with
318 additions
and
289 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from __future__ import annotations | ||
|
||
import tracemalloc | ||
|
||
import numpy as np | ||
|
||
from .utils import gen_adata | ||
|
||
|
||
class GarbargeCollectionSuite: | ||
runs = 10 | ||
|
||
# custom because `memory_profiler` is a line-by-line profiler (also: https://github.com/pythonprofilers/memory_profiler/issues/402) | ||
def track_peakmem_garbage_collection(self, *_): | ||
def display_top(snapshot, key_type="lineno"): | ||
snapshot = snapshot.filter_traces( | ||
( | ||
tracemalloc.Filter(False, "<frozen importlib._bootstrap>"), | ||
tracemalloc.Filter(False, "<unknown>"), | ||
) | ||
) | ||
top_stats = snapshot.statistics(key_type) | ||
total = sum(stat.size for stat in top_stats) | ||
return total | ||
|
||
total = np.zeros(self.runs) | ||
tracemalloc.start() | ||
for i in range(self.runs): | ||
data = gen_adata(10000, 10000, "X-csc") # noqa: F841 | ||
snapshot = tracemalloc.take_snapshot() | ||
total[i] = display_top(snapshot) | ||
tracemalloc.stop() | ||
return max(total) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.