How to time BehaviorSpace runs?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to time BehaviorSpace runs?

Andreas Pape
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 netlogo-users! Happy holidays, everyone!


                —Andreas Pape, Binghamton University (SUNY)
Reply | Threaded
Open this post in threaded view
|

Re: How to time BehaviorSpace runs?

Steve Railsback
Hi Andreas,

a) I suppose you could add some code to the "Final commands" dialog in BehaviorSpace to write "timer" to a file.

b) We published a paper on how to time and speed up NetLogo models. See:
http://www.railsback-grimm-abm-book.com/JASSS-models.html http://www.railsback-grimm-abm-book.com/JASSS-models.html

Steve Railsback
Reply | Threaded
Open this post in threaded view
|

Re: How to time BehaviorSpace runs?

Andreas Pape
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-open "timers.csv"
        file-print (sentence ExperimentName "," thetime "," date-and-time )
        file-close
end



Andreas Duus Pape
Associate Professor and Director of Graduate Studies
Economics Department
Binghamton University


> On Jan 1, 2018, at 10:56 AM, [hidden email] [netlogo-users] <[hidden email]> wrote:
>
> Hi Andreas,
>
> a) I suppose you could add some code to the "Final commands" dialog in BehaviorSpace to write "timer" to a file.
>
> b) We published a paper on how to time and speed up NetLogo models. See:
> http://www.railsback-grimm-abm-book.com/JASSS-models.html <http://www.railsback-grimm-abm-book.com/JASSS-models...html>
>
> Steve Railsback
>
>