I wonder is there any function in NEURON that similar to tic() and toc() in Matlab?
I would like to use it to record processing time of my simulation.
After going through Documentation and threads here, I couldn't find it.
Thank you in advance.
Timer in NEURON ( similar to tic() and toc() in Matlab)
Re: Timer in NEURON ( similar to tic() and toc() in Matlab)
I found one variable that could show the simulation time, that is "realtime".
It did not work similarly like tic() and toc() function in MATLAB that could be use as a timer anywhere in your code, however. But I could get along with it for now.
It did not work similarly like tic() and toc() function in MATLAB that could be use as a timer anywhere in your code, however. But I could get along with it for now.
-
- Site Admin
- Posts: 6289
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
Re: Timer in NEURON ( similar to tic() and toc() in Matlab)
You want startsw(); see documentation in the Programmer's Reference.
Code: Select all
t0 = startsw()
. . . model setup code . . .
t1 = startsw()
run() // executes a simulation
t2 = startsw()
print "model setup time ", t1-t0, " run time ", t2-t1, " total ", t2-t0
-
- Site Admin
- Posts: 6289
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
Re: Timer in NEURON ( similar to tic() and toc() in Matlab)
startsw isn't a very "obvious" name for such a function, but if you dig into stdrun.hoc you'll find that realtime is calculated from values returned by calls to startsw.
Time for two big hints.
1. NEURON's standard run system is implemented almost entirely in hoc, and this hoc code is contained in the hoc library, which is in nrn/lib/hoc. There's lots of interesting and reusable code in the hoc library, and it's a good idea to browse through it.
2. If you come across a particular variable or class or procedure or function whose name is not defined in the Programmer's Reference, this means it is not built into hoc. Instead, it will either be defined in the hoc library, which is in nrn/lib/hoc, or by code contained in a user-written hoc or NMODL file.
"Oh, but RealTime actually is in the Programmer's Reference."
True, because RealTime is a label that appears on a button in the RunControl panel, and the Programmer's Reference contains a description of what this label means. However, never forget that hoc is case-sensitive. "RealTime" is not the name of any hoc variable. Neither is the variable called "realtime"--that variable is defined in stdrun.hoc and is not one of hoc's built-in variables.
Time for two big hints.
1. NEURON's standard run system is implemented almost entirely in hoc, and this hoc code is contained in the hoc library, which is in nrn/lib/hoc. There's lots of interesting and reusable code in the hoc library, and it's a good idea to browse through it.
2. If you come across a particular variable or class or procedure or function whose name is not defined in the Programmer's Reference, this means it is not built into hoc. Instead, it will either be defined in the hoc library, which is in nrn/lib/hoc, or by code contained in a user-written hoc or NMODL file.
"Oh, but RealTime actually is in the Programmer's Reference."
True, because RealTime is a label that appears on a button in the RunControl panel, and the Programmer's Reference contains a description of what this label means. However, never forget that hoc is case-sensitive. "RealTime" is not the name of any hoc variable. Neither is the variable called "realtime"--that variable is defined in stdrun.hoc and is not one of hoc's built-in variables.