From aeec6cfafed8df110e60743073cff6d778f65af0 Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Mon, 29 Sep 2014 18:45:10 +0200 Subject: +cython version for isi and performance tests --- examples/perf_isi.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ examples/perf_spike.py | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 examples/perf_isi.py create mode 100644 examples/perf_spike.py (limited to 'examples') diff --git a/examples/perf_isi.py b/examples/perf_isi.py new file mode 100644 index 0000000..8b44946 --- /dev/null +++ b/examples/perf_isi.py @@ -0,0 +1,46 @@ +# performance measure of the isi calculation + +from __future__ import print_function + +import numpy as np +import matplotlib.pyplot as plt +import time +from functools import partial + +import pyspike as spk +#import pyspike.distances # for the python functions + +def measure_perf(func, loops=10): + times = np.empty(loops) + for i in xrange(loops): + start = time.clock() + func() + times[i] = time.clock() - start + return np.min(times) + +print("# approximate number of spikes\tcython time [ms]\tpython time [ms]") + +# fix seed to get reproducible results +np.random.seed(1) + +# max times +Ns = np.arange(10000, 50001, 10000) +for N in Ns: + + # first generate some data + times = 2.0*np.random.random(1.1*N) + t1 = np.cumsum(times) + # only up to T + t1 = spk.add_auxiliary_spikes(t1[t1