Skip to content

Commit

Permalink
Converted synstat script to use KB instead of MB
Browse files Browse the repository at this point in the history
  • Loading branch information
st4rl3ss committed Aug 10, 2023
1 parent 61e6385 commit befc404
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions _benchmarks/synstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

def get_mem_usage():
"""
Return memory usage information in MB.
Return memory usage information in KB.
"""
with open("/proc/self/statm") as fd:
_, data_size, _ = fd.read().split(maxsplit=2)
usage_mb = float(data_size) * os.sysconf("SC_PAGE_SIZE") / 1024 ** 2
usage_kb = float(data_size) * os.sysconf("SC_PAGE_SIZE") / 1024

return usage_mb
return usage_kb


# Dummy class to pass to synapse objects
Expand Down Expand Up @@ -42,23 +42,23 @@ def __getattr__(self, item):
AMPA_helper = [h.AMPANMDAHelper(1, params_obj, 0.5, i, 0) for i in range(n_inst)]
netcon_ampa = [pc.gid_connect(1000, helper.synapse) for helper in AMPA_helper]
mem2 = get_mem_usage()
print('Memory usage per object ProbAMPA: %f KB' % ((mem2 - mem) / n_inst * 1024))
print('Memory usage per object ProbAMPA: %f KB' % ((mem2 - mem) / n_inst))

h.load_file("GABAABHelper.hoc")
mem = get_mem_usage()
GABAAB_helper = [h.GABAABHelper(1, params_obj, 0.5, i, 0) for i in range(n_inst)]
netcon_gabaab = [pc.gid_connect(1000, helper.synapse) for helper in GABAAB_helper]
mem2 = get_mem_usage()
print('Memory usage per object ProbGABAAB: %f KB' % ((mem2 - mem) / n_inst * 1024))
print('Memory usage per object ProbGABAAB: %f KB' % ((mem2 - mem) / n_inst))

h.load_file("GluSynapseHelper.hoc")
mem = get_mem_usage()
GluSynapse_helper = [h.GluSynapseHelper(1, params_obj, 0.5, i, 0, map_hoc) for i in range(n_inst)]
netcon_glu = [pc.gid_connect(1000, helper.synapse) for helper in GluSynapse_helper]
mem2 = get_mem_usage()
print('Memory usage per object GluSynapse: %f KB' % ((mem2 - mem) / n_inst * 1024))
print('Memory usage per object GluSynapse: %f KB' % ((mem2 - mem) / n_inst))

mem = get_mem_usage()
Gap_helper = [h.Gap(0.5) for i in range(n_inst)]
mem2 = get_mem_usage()
print('Memory usage per object Gap: %f KB' % ((mem2 - mem) / n_inst * 1024))
print('Memory usage per object Gap: %f KB' % ((mem2 - mem) / n_inst))

0 comments on commit befc404

Please sign in to comment.