Closed AdrickTench closed 3 weeks ago
!(,(get-time!) (sleep! 1) (get-time!)) [(, 1726774806.2906268 True 1726774807.2910154)]
I see get-time! is wall time and time! is using cputime.. good find!
we need a (time $Eval) and a without a bang !
like (because time!
is really time/1
This should be pretty easy to implement! (Marking this as a good first issue)
So the idea woudl be to write two predicates:
(time (sleep! 1)) -> 1.0 secs (cpu-time (sleep! 1)) -> 000000000000001 secs
metta+>!(time (sleep! 1))
[
; eval_args([sleep!,1]) took 1.000 secs. (1000.00 milliseconds)
True]
metta+>!(catch! (max-time! 1 (sleep! 2)) time_limit_exceeded time_limit_exceeded)
[time_limit_exceeded]
The following demonstrates
time!
fails to timesleep!
accurately, and likewisemax-time!
fails to abortsleep!