NeuromorphicProcessorProject / snn_toolbox

Toolbox for converting analog to spiking neural networks (ANN to SNN), and running them in a spiking neuron simulator.
MIT License
360 stars 104 forks source link

How to measure run time of simulation #62

Closed RKCZ closed 4 years ago

RKCZ commented 4 years ago

Hi, what would be the right way to measure how long does a simulation run in real time? Is it possible to measure it?

rbodo commented 4 years ago

You mean for instance a simulation using the default INIsim?

You could just place a timeit around this line:

import time
start_time = time.time()
output_b_l_t = self.simulate(**data_batch_kwargs)
end_time = time.time()
time_per_batch = end_time - start_time

That gives you the time to run one batch, but includes some post-processing of the result and recorded states (spikes, membrane potentials etc), if so specified in your config.

To get a more fine-grained measurement, time the actual call to the predict method here, which will give you the wall clock time it takes to process one time step in rate-based INIsim.

Just be aware that these measurements are of limited value as this particular simulator is not really optimized for SNNs; each time step is basically a forward pass of the network on a GPU/CPU. It would be more interesting to time a simulator that's based on an actual SNN emulation framework like Brian or Nest, or of course using SNN hardware like SpiNNaker and Loihi.

RKCZ commented 4 years ago

Thank you for the advice, I measured the batch time as you hinted me.