-
-
Save btel/9d5c98ca27d24780a4a4 to your computer and use it in GitHub Desktop.
profiling of elephant.spike_train_correlation.cross_correlation_histogram
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
To see simple statistics, run without arguments: | |
$ python profile_cch.py | |
To save results to file, provide a filename: | |
$ python profile_cch.py my.csv | |
You can compare results from different version. First checkout a different branch of elephant, then run the benchmark again: | |
$ python profile_cch.py other_branch.csv | |
To display results: | |
$ python show_stats.py *.csv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
memory | rate | speed | t_stop | window_width | |
---|---|---|---|---|---|
21.5274269581 | 1000 | 0.0313630104065 | 100 | 50.0 | |
0.0159041881561 | 1 | 0.0298500061035 | 100 | 50.0 | |
0.0318510532379 | 1 | 31.2070081234 | 100 | 100000.0 | |
253.660431862 | 1000 | 31.3886771202 | 100 | 100000.0 | |
0.0258219242096 | 1 | 44.6426329613 | 100 | ||
333.329719067 | 1000 | 45.046806097 | 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
memory | rate | speed | t_stop | window_width | |
---|---|---|---|---|---|
47.6465260983 | 1000 | 35.5723581314 | 100 | 50.0 | |
0.0157039165497 | 1 | 34.3674120903 | 100 | 50.0 | |
0.0182638168335 | 1 | 34.483782053 | 100 | 100000.0 | |
288.690366983 | 1000 | 35.324805975 | 100 | 100000.0 | |
0.0256409645081 | 1 | 45.2430369854 | 100 | ||
435.867851019 | 1000 | 44.6380541325 | 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import timeit | |
import quantities as pq | |
import elephant.spike_train_correlation as corr | |
from elephant.conversion import BinnedSpikeTrain | |
from functools import partial | |
from elephant.spike_train_generation import homogeneous_poisson_process as poisson | |
from collections import namedtuple | |
import pandas as pd | |
import sys | |
results = [] | |
runs = 5 | |
Params = namedtuple("Params", ['t_stop', 'rate', 'window_width']) | |
param_list = [Params(100, 1000 , 50.), | |
Params(100, 1, 50.), | |
Params(100, 1, 100000), | |
Params(100, 1000, 100000), | |
Params(100, 1, None), | |
Params(100, 1000, None)] | |
for p in param_list: | |
benchmark = {} | |
spikedata = [poisson(p.rate * pq.Hz, t_start=0 * pq.s, t_stop=p.t_stop * pq.s) for _ in range(2)] | |
st1 = BinnedSpikeTrain(spikedata[0], binsize=1 * pq.ms) | |
st2 = BinnedSpikeTrain(spikedata[1], binsize=1 * pq.ms) | |
if p.window_width: | |
window=[-p.window_width * pq.ms/ 2., p.window_width * pq.ms/ 2.] | |
else: | |
window = None | |
for method in ['speed', 'memory']: | |
func = partial(corr.cross_correlation_histogram, st1, st2, window=window, method=method) | |
timer = timeit.Timer(func) | |
benchmark[method] = timer.timeit(runs) | |
benchmark.update(p._asdict()) | |
results.append(benchmark) | |
df = pd.DataFrame(results) | |
if len(sys.argv) > 1: | |
df.to_csv(sys.argv[1], index=False) | |
else: | |
print(df.set_index(['rate', 't_stop', 'window_width'])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# benchmark results | |
# btel: git commit 59a9c57 | |
# pietro: git commit 62e1db | |
btel pietro | |
memory speed memory speed | |
rate t_stop window_width | |
1000 100 50 21.527427 0.031363 47.646526 35.572358 | |
1 100 50 0.015904 0.029850 0.015704 34.367412 | |
100000 0.031851 31.207008 0.018264 34.483782 | |
1000 100 100000 253.660432 31.388677 288.690367 35.324806 | |
1 100 NaN 0.025822 44.642633 0.025641 45.243037 | |
1000 100 NaN 333.329719 45.046806 435.867851 44.638054 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#coding=utf-8 | |
import pandas as pd | |
import sys | |
import os | |
if __name__ == "__main__": | |
data_frames = {} | |
fullpaths = sys.argv[1:] | |
for fullpath in fullpaths: | |
path, fname = os.path.split(fullpath) | |
core, ext = os.path.splitext(fname) | |
df = pd.DataFrame.from_csv(fullpath) | |
df = df.reset_index() | |
df2 = df.set_index(['rate', 't_stop', 'window_width']) | |
data_frames[core] = df2 | |
merged = pd.concat(data_frames, axis=1) | |
print(merged) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment