If you’d like your model to run faster, the profiler extension may be useful to you. It includes primitives that measure how many times the procedures in your model are called during a run and how long each call takes. You can use this information to where to focus your speedup efforts.
Caution:
The profiler extension is experimental. It is not yet well tested or user friendly. Nonetheless, we think some users will find it useful.
The profiler extension comes preinstalled. To use the extension in your model, add a line to the top of your Code tab:
extensions [profiler]
If your model already uses other extensions, then it already has an
extensions
line in it, so just add profiler
to the list.
For more information on using NetLogo extensions, see the Extensions Guide
setup ;; set up the model
profiler:start ;; start profiling
repeat 20 [ go ] ;; run something you want to measure
profiler:stop ;; stop profiling
print profiler:report ;; view the results
profiler:reset ;; clear the data
Thanks to Roger Peppe for his contributions to the code.
profiler:calls
profiler:exclusive-time
profiler:inclusive-time
profiler:start
profiler:stop
profiler:reset
profiler:report
Reports the number of times that procedure-name was called. If procedure-name is not defined, then reports 0.
Reports the exclusive time, in milliseconds, that procedure-name was running for. Exclusive time is the time from when the procedure was entered, until it finishes, but does not include any time spent in other user-defined procedures which it calls.
If procedure-name is not defined, then reports 0.
Reports the inclusive time, in milliseconds, that procedure-name was running for. Inclusive time is the time from when the procedure was entered, until it finishes.
If procedure-name is not defined, then reports 0.
Instructs the profiler to begin recording user-defined procedure calls.
Reports a string containing a breakdown of all user-defined procedure
calls. The Calls
column contains the number of times a
user-defined procedure was called. The Incl T(ms)
column
is the total time, in milliseconds, it took for the call to complete,
including the time spent in other user-defined procedures. The
Excl T(ms)
column is the total time, in milliseconds,
spent within that user-defined procedure, not counting other
user-define procedures it called. The Excl/calls
column
is an estimate of the time, in milliseconds, spent in that
user-defined procedure for each call.
Here is example output:
Sorted by Exclusive Time
Name Calls Incl T(ms) Excl T(ms) Excl/calls
CALLTHEM 13 26.066 19.476 1.498
CALLME 13 6.413 6.413 0.493
REPORTME 13 0.177 0.177 0.014
Sorted by Inclusive Time
Name Calls Incl T(ms) Excl T(ms) Excl/calls
CALLTHEM 13 26.066 19.476 1.498
CALLME 13 6.413 6.413 0.493
REPORTME 13 0.177 0.177 0.014
Sorted by Number of Calls
Name Calls Incl T(ms) Excl T(ms) Excl/calls
CALLTHEM 13 26.066 19.476 1.498