MCPcopy Create free account
hub / github.com/BindsNET/bindsnet / memory_benchmark

Function memory_benchmark

examples/benchmark/sparse_vs_dense_tensors.py:31–59  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29
30
31def memory_benchmark():
32 print(
33 "======================= ====================== ====================== ===================="
34 )
35 print(
36 "Sparse (megabytes used) Dense (megabytes used) Ratio (Sparse/Dense) % % of non zero values"
37 )
38 print(
39 "======================= ====================== ====================== ===================="
40 )
41 percent_of_true_values = 0.005
42 while percent_of_true_values < 0.1:
43 result = {}
44 for sparse in [True, False]:
45 result[sparse] = create_spikes_tensor(percent_of_true_values, sparse)
46 percent = round((result[True] / result[False]) * 100)
47
48 row = [
49 str(result[True]).ljust(23),
50 str(result[False]).ljust(22),
51 str(percent).ljust(22),
52 str(round(percent_of_true_values * 100, 1)).ljust(20),
53 ]
54 print(" ".join(row))
55 percent_of_true_values += 0.005
56
57 print(
58 "======================= ====================== ====================== ===================="
59 )
60
61
62def run(sparse):

Callers 1

Calls 1

create_spikes_tensorFunction · 0.85

Tested by

no test coverage detected