2

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?

false
  • 10,264
  • 13
  • 101
  • 209
rwehresmann
  • 1,108
  • 2
  • 11
  • 27

1 Answers1

2

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.

Community
  • 1
  • 1
repeat
  • 18,496
  • 4
  • 54
  • 166