Get predicate execution time in seconds

2019-07-15 15:12发布

问题:

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?

回答1:

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.



标签: prolog