Created
March 2, 2016 09:38
-
-
Save myarik/e009c0c881b49d1199c5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Simple way | |
from pympler import summary, muppy | |
def go(): | |
list1 = [] | |
f = 5 | |
for i in range(10000000): | |
f += 1 | |
list1.append(f) | |
go() | |
all_objects = muppy.get_objects() | |
sum1 = summary.summarize(all_objects) | |
summary.print_(sum1) | |
# Find diff | |
from pympler import summary, muppy | |
sum1 = summary.summarize(muppy.get_objects()) | |
summary.print_(sum1) | |
list1 = [] | |
f = 5 | |
for i in range(1000000): | |
f += 1 | |
list1.append(f) | |
sum2 = summary.summarize(muppy.get_objects()) | |
diff = summary.get_diff(sum1, sum2) | |
summary.print_(diff) | |
# Lib objgraph | |
import objgraph | |
objgraph.show_most_common_types() | |
# Lib guppy | |
from guppy import hpy | |
hp = hpy() | |
before = hp.heap() | |
# critical section here | |
# | |
after = hp.heap() | |
leftover = after - before | |
import pdb; pdb.set_trace() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment