如何在Julia中设置一段代码的运行时间

已知测试一段代码的运行时间可以用@btime、@time等函数,那么如何设置运行一段代码的时间?比如100秒、200秒这样?

@time include("xxx.jl")
或许有更好的方法。

是这个吗

help?> ?Base.Timer
  Timer(delay; interval = 0)

  Create a timer that wakes up tasks waiting for it (by calling wait on the timer object).

  Waiting tasks are woken after an initial delay of at least delay seconds, and then
  repeating after at least interval seconds again elapse. If interval is equal to 0, the
  timer is only triggered once. When the timer is closed (by close) waiting tasks are
  woken with an error. Use isopen to check whether a timer is still active.

其示例代码

  # Here the first number is printed after a delay of two seconds, then the following
  # numbers are printed quickly.

  julia> begin
             i = 0
             cb(timer) = (global i += 1; println(i))
             t = Timer(cb, 2, interval=0.2)
             wait(t)
             sleep(0.5)
             close(t)
         end
  1
  2
  3

社区中找到了定时器的使用方法,我再研究研究,谢谢你!