Hello netlogo-users. I’m trying to optimize the time it takes for my BehaviorSpace experiments to run. I have two topics about that.
TOPIC 1: Runtime measurement.
I’m trying to reliably (automatically) record the time each run (or set of runs) takes. Here are my ideas:
T1, Q1) Is there a built-in way to save the “Total Elapsed Time” that appears in the dialog box?
T1, Q2) I’ve discovered the “timer” function. So I’ve put “reset-timer” in my Setup function, and then I can collect the variable “timer” at the end of the run. This works…except in the long run, I wish to collect data at every step, not just at the end of the run…I’d rather not clutter up my data files with the timer every step. Is there a way to save “timer” only at the end of the run?
T1, Q3) Is there some other method?
TOPIC 2: General time-saving tips
T2, Q1) I’ve heard it can be a significant savings to not “build your own” loops and instead rely on NetLogo’s built-in lists and “ask” and “foreach”s. Is that true? Tips in this regard?
T2, Q2) Any other typical tips? Things that are easy to tweak to bring down runtime?
Thanks Steve. That’s a good solution. For anyone else facing this, I just added this function and then add “my-timer MYEXPERIMENT” to the “Final commands.” It collects all the timers in a .csv file. A tidy solution!
to my-timer [ ExperimentName ]
let thetime timer
file-print (sentence ExperimentName "," thetime "," date-and-time )
Andreas Duus Pape
Associate Professor and Director of Graduate Studies