在NetLogo中运行过程的时间 [英] Time for a procedure to run in NetLogo

查看:178
本文介绍了在NetLogo中运行过程的时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何找到在NetLogo中运行过程所花费的时间?

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

使用NetLogo中定义的滴答"对我而言是不准确的.

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

一个模糊的想法是减去开始和结束时的系统时间 可能的话.

A vague idea would to subtract the system time at the start and end of procedure if possible.

但是我不知道NetLogo中定义的任何允许我执行此操作的方法.

But I am unaware of any methods defined in NetLogo which would allow me to do this.

推荐答案

Charles对Profiler扩展的建议很棒.分析器扩展非常有用.但是,对于您的情况,这可能会显得过分.

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

结帐 reset-timer

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

如果您想了解一个过程所花费的平均时间,只需将其放在repeat块中即可:

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

这篇关于在NetLogo中运行过程的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆