Prologue: What does the result of time / 1 call mean?

I'm new to Prolog (and pretty new to CS / programming in general), and I'm trying to evaluate and improve the performance of my programs using the time / 1 predicate. However, I'm not sure I understand the way out. For example, the request time ("MyProgram") gives the following result in addition to the "MyProgram" solution:

% 34,865,980 inferences, 4.479 CPU in 4.549 seconds (98% CPU, 7784905 Lips)

What does it mean? There are several explanations here, but I find this not enough.

Thanks in advance!

+4
source share
2 answers

Value follows . Basic data is selected using the following calls:

  get_time(Wall)
  statistics(cputime, Time)
  statistics(inferences, Inferences)

Then the following is displayed:

'% 1,% 2 CPU % 3 (% 4% CPU,% 5 )'
% 1: 2-1
% 2: Time2-Time1
% 3: Wall2-Wall1
% 4: (100 *% 2/% 3)
% 5: (% 1/% 2)

% 2 = < % 3, GC, % 4 100. /, , .

+1

-, . Prolog . ECLiPSe, Prolog , .

:

equal_to_one(X) :- X =:= 1.

(, , , Prolog), :

?- trace, foo(1).
   Call: (7) foo(1) ? creep
   Call: (8) 1=:=1 ? creep
   Exit: (8) 1=:=1 ? creep
   Exit: (7) foo(1) ? creep

, . foo (1) / Prolog foo/1, (). , ( ).

/1, :

?- time(foo(1)).
   % 2 inferences, 0.000 CPU in 0.000 seconds (86% CPU, 69691 Lips)
   true.

?- time(foo(2)).
   % 2 inferences, 0.000 CPU in 0.000 seconds (82% CPU, 77247 Lips)
   false.

() . , (.. " " - , , ). - , - , .

, CPU , , ( . SO).

, % CPU LIPS . , , .

PS: SO

0

All Articles