I'm looking a way to get the time execution of a predicate in seconds, using swi-prolog. I found the time(X)
who brings me this information and much more, but what I need is only the time in seconds, wath I would like to write after run the predicate.
There is a way to do that?
To get the elapsed runtime passed while executing a specified goal you can use call_time/2
:
?- call_time(true,T_ms).
T_ms = 0.
Be aware that T_ms
measures milliseconds, not seconds!
To get to seconds use an additional goal like T is T_ms * 0.001
.
For a list of concrete uses of call_time/2
, look at these search results.