Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repeated sim.data[probe] accesses are very slow #1076

Closed
arvoelke opened this issue May 30, 2016 · 0 comments
Closed

Repeated sim.data[probe] accesses are very slow #1076

arvoelke opened this issue May 30, 2016 · 0 comments
Assignees

Comments

@arvoelke
Copy link
Contributor

arvoelke commented May 30, 2016

import time
import nengo

with nengo.Network() as model:
    x = nengo.Ensemble(1000, 1)
    p_neurons = nengo.Probe(x.neurons)

with nengo.Simulator(model) as sim:
    sim.run(10)

# Repeated probe accesses
start = time.time()
for m in range(x.n_neurons):
    sim.data[p_neurons][0, m]
print time.time() - start

# Only one probe access
start = time.time()
u = sim.data[p_neurons][0, :]
for m in range(x.n_neurons):
    u[m]
print time.time() - start

It takes 37 seconds on my computer to access a mere 1000 spikes. It looks like every time sim.data[p_neurons] is accessed the entire array is re-copied. And of course the same effect is seen when accessing various time points.

Perhaps we should be caching the read-only object?

@jgosmann jgosmann self-assigned this Sep 14, 2016
jgosmann added a commit that referenced this issue Sep 21, 2016
This makes repeated access faster.

Fixes #1076.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants