Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add a new memleak script that does everything #5360

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 5, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix average increase calculation by tracking peaks
  • Loading branch information
mdboom committed Nov 2, 2015
commit 6572456e58503c3048fbdddf18f30163025d6154
7 changes: 6 additions & 1 deletion unit/memleak.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ def run_memleak_test(bench, iterations, report):

malloc_arr = np.empty((endi,), dtype=np.int64)
rss_arr = np.empty((endi,), dtype=np.int64)
rss_peaks = np.empty((endi,), dtype=np.int64)
nobjs_arr = np.empty((endi,), dtype=np.int64)
garbage_arr = np.empty((endi,), dtype=np.int64)
rss_peak = 0

for i in range(endi):
bench()
Expand All @@ -34,11 +36,14 @@ def run_memleak_test(bench, iterations, report):

malloc_arr[i] = malloc
rss_arr[i] = rss
if rss > rss_peak:
rss_peak = rss
rss_peaks[i] = rss_peak
nobjs_arr[i] = nobjs
garbage_arr[i] = garbage

print('Average memory consumed per loop: %1.4f bytes\n' %
(np.sum(rss_arr[starti+1:] - rss_arr[starti:-1]) / float(endi - starti)))
(np.sum(rss_peaks[starti+1:] - rss_peaks[starti:-1]) / float(endi - starti)))

from matplotlib import pyplot as plt
fig, (ax1, ax2) = plt.subplots(2)
Expand Down