trueagi-io / metta-wam

A Hyperon MeTTa Interpreter/Transpilier that targets the Warren Abstract Machine
8 stars 11 forks source link

timing doesn't work properly #128

Closed AdrickTench closed 3 weeks ago

AdrickTench commented 1 month ago

The following demonstrates time! fails to time sleep! accurately, and likewise max-time! fails to abort sleep!

metta+>!(time! (sleep! 1))
[
; eval_args([sleep!,1]) took 0.000298 secs. (298.50 microseconds)

True]
metta+>!(catch! (max-time! 1 (sleep! 2)) time_limit_exceeded time_limit_exceeded)
[True]
TeamSPoon commented 1 month 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

TeamSPoon commented 3 weeks ago
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]