I want to see the execution time inside goals of predicate with SICStus Prolog.
Example :
pred :-
goal1,
time
I'd like to add two thoughts:
Prolog allows for backtracking, so goals may succeed more than once.
What's the "runtime" you are interested in?
Use statistics/2, but don't do it directly. Instead, use an abstraction like call_time/2.
Sample query:
?- call_time((permutation([a,b,c,d,e,f,g,h,i],Xs),Xs=[_,_,g,f,e,d,c,b,a]), T_ms). Xs = [h, i, g, f, e, d, c, b, a], T_ms = 304 ; Xs = [i, h, g, f, e, d, c, b, a], T_ms = 345 ; false.
Notice that call_time/2
succeeds twice and T_ms
measures total runtime up to this point.