| 1 |
import pickle |
| 2 |
|
| 3 |
import matplotlib.pyplot as plt |
| 4 |
import numpy as np |
| 5 |
|
| 6 |
with open('synapse_creation_times_brian1.pickle', 'r') as f: |
| 7 |
brian1_results = pickle.load(f) |
| 8 |
with open('synapse_creation_times_brian2.pickle', 'r') as f: |
| 9 |
brian2_results = pickle.load(f) |
| 10 |
|
| 11 |
results = brian1_results |
| 12 |
results.update(brian2_results) |
| 13 |
|
| 14 |
conditions = [('Full', True), |
| 15 |
('Full (no-self)', 'i != j'), |
| 16 |
('One-to-one', 'i == j'), |
| 17 |
('Simple neighbourhood', 'abs(i-j) < 5'), |
| 18 |
('Gauss neighbourhood', 'exp(-(i - j)**2/5) > 0.005'), |
| 19 |
('Random (50%)', 0.5), |
| 20 |
('Random (10%)', 0.1), |
| 21 |
('Random (1%)', 0.01), |
| 22 |
('Random no-self (50%)', '(i != j) * 0.5'), |
| 23 |
('Random no-self (10%)', '(i != j) * 0.1'), |
| 24 |
('Random no-self (1%)', '(i != j) * 0.01')] |
| 25 |
targets = ['PythonLanguage', 'CPPLanguage', 'Brian 1'] |
| 26 |
# nicer names for the labels |
| 27 |
lang_translation = {'PythonLanguage': 'Brian 2 (Python)', |
| 28 |
'CPPLanguage': 'Brian 2 (C++)', |
| 29 |
'Brian 1': 'Brian 1'} |
| 30 |
|
| 31 |
# Do some plots |
| 32 |
for pattern, condition in conditions: |
| 33 |
plt.figure() |
| 34 |
for lang_name in targets: |
| 35 |
data = [(connections, time) for ((lang, connections, p), time) in results.items() |
| 36 |
if lang == lang_name and p == pattern] |
| 37 |
data.sort(key=lambda item: item[0]) |
| 38 |
data = np.array(data).T |
| 39 |
plt.plot(data[0], data[1], 'o-', label=lang_translation[lang_name]) |
| 40 |
plt.xscale('log') |
| 41 |
plt.yscale('log') |
| 42 |
plt.xlabel('Number of created connections') |
| 43 |
plt.ylabel('time (s)') |
| 44 |
plt.legend(loc='best', frameon=False) |
| 45 |
plt.title('%s: "%s"' % (pattern, condition)) |
| 46 |
plt.savefig('plots/%s.png' % pattern.replace(' ', '_')) |