Time for a procedure to run in NetLogo

后端 未结 1 1460
醉话见心
醉话见心 2020-12-21 02:18

How can I find the time it took to run a procedure in NetLogo?

Using \'ticks\' defined in NetLogo is inaccurate for my purposes.

A vague idea would to subtr

相关标签:
1条回答
  • 2020-12-21 02:41

    Charles' suggestion of the profiler extension is a great. The profiler extension is incredibly useful. However, it may be overkill for your situation.

    Checkout reset-timer and timer. reset-timer sets an internal timer to 0, and then timer reports the amount of time that has passed since reset-timer was called (in seconds). The resolution is on the order of milliseconds, but depends on the system.

    To time a single procedure call, you'd do something like:

    reset-timer
    my-procedure
    print timer
    

    If you want to get a sense of the average time a procedure takes, you can simply put it in a repeat block:

    reset-timer
    repeat 1000 [ my-procedure ]
    print timer
    
    0 讨论(0)
提交回复
热议问题