Skip to content

Commit

Permalink
Add memory usage debug function
Browse files Browse the repository at this point in the history
  • Loading branch information
CalebBell committed May 23, 2022
1 parent 3db1e09 commit ef1b447
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion chemicals/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,21 @@ def constant_statistics():
else:
counts[p] = set(prop_CASs)
return {k: len(v) for k, v in counts.items()}


def memory_usage(finish_loading=True):
if finish_loading:
complete_lazy_loading()
usages = []
names = []
for name, df in data_reader.df_sources.items():
names.append(name)
usages.append(df.memory_usage().values.sum())

names = [x for _, x in sorted(zip(usages, names))]
usages.sort()
for name, use in zip(names, usages):
print(f'{name} : {use/1024**2:3f} MB')
print(f'Total usage: {sum(usages)/1024**2:3f} MB')

global vectorized, numba, units, numba_vectorized
if PY37:
Expand Down

0 comments on commit ef1b447

Please sign in to comment.