Display the execution times for each goal of a predicate clause

前端 未结 3 508
遇见更好的自我
遇见更好的自我 2021-01-13 04:21

I want to see the execution time inside goals of predicate with SICStus Prolog.

Example :

pred :-
   goal1,
   time         


        
3条回答
  •  既然无缘
    2021-01-13 04:41

    Since nobody mentioned it, if you only want a time display the time/1 predicate can be also useful. It is already supported by a couple of Prolog systems such as SWI-Prolog, Jekejeke Prolog, O-Prolog, etc...:

    Welcome to SWI-Prolog (threaded, 64 bits, version 7.7.19)
    
    ?- time((between(1,10000000,_), fail; true)).
    % 10,000,001 inferences, 0.453 CPU in 0.468 seconds (97% CPU, 22068968 Lips)
    true.
    

    Unfortunately Prolog systems such as GNU Prolog, SICStus Prolog dont support it. But its the analog of the Unix time command, in that it is a meta predicate that takes a goal argument. Better than stone age methods.

提交回复
热议问题