COUNT = 10000 STEP = 100 x = np.linspace(1, COUNT, COUNT / STEP) y = np.empty(COUNT / STEP, dtype=int) i = 0 for contact in site.members._tree.itervalues(): contact.getId() # make sure the object's not a ZODB ghost if not i % STEP: y[i / STEP] = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1000 i += 1 if i >= COUNT: break plt.plot(x, y, 'bo') plt.xlabel('Objects loaded') plt.ylabel('RAM used (KB)') contact_size = (y[-1] - y[0]) / float(COUNT) print '%0.2f KB' % contact_size contact = site.members['david-glick'] contact.getId() contact_pickle_size = contact._p_estimated_size / 1000.0 print '%0.2f KB' % contact_pickle_size print '%0.2f' % (contact_size / contact_pickle_size) from IPython.display import HTML def analyze_dict(o): h = '
Key | Value | Size (Bytes) |
---|---|---|
[obj] | %s | |
[obj.__dict__] | %s | |
%s | %s | %s | ' % (k, repr(v), size) h += '
(TOTAL) | %s | ' % total h += '