2
votes

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
Check out statistics/2: Measure the time difference before and after calling the goal.mat
try ?- profile(your_predicate). then enjoy the graphical interface...CapelliC
statistics(runtime,[Start_ms,Last_ms]) works the same way as in SICStus, YAP, B, GNU.false

1 Answers

2
votes

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.