Skip to content

Commit

Permalink
Review changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
pp-mo committed May 15, 2024
1 parent 074d3a1 commit d9232df
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions benchmarks/benchmarks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,17 @@ def __enter__(self):
return self

def __exit__(self, *_):
_, peak_mem = tracemalloc.get_traced_memory()
_, peak_mem_bytes = tracemalloc.get_traced_memory()
tracemalloc.stop()
self._peak_mb = peak_mem * 1.0 / 1024**2
# Save peak-memory allocation, scaled from bytes to Mb.
self._peak_mb = peak_mem_bytes * (2.0**-20)

def addedmem_mb(self):
"""Return measured memory growth, in Mb."""
result = self._peak_mb
# Small results are too vulnerable to noise being interpreted as signal.
result = max(self.RESULT_MINIMUM_MB, result)
# Rounding makes results easier to read.
result = np.round(result, self.RESULT_ROUND_DP)
return result

Expand Down

0 comments on commit d9232df

Please sign in to comment.