is called, the profiler executes the Goal in the profiling mode, which means that every 100th of a second the execution is interrupted and the profiler records the currently executing procedure.?- profile(Goal).
From the above result we can see how the profiler output contains four important areas of information:?- profile(queen([1,2,3,4,5,6,7,8,9],Out)). goal succeeded PROFILING STATISTICS -------------------- Goal: queen([1, 2, 3, 4, 5, 6, 7, 8, 9], Out) Total user time: 0.03s Predicate Module %Time Time %Cum -------------------------------------------------------- qdelete /4 eclipse 50.0% 0.01s 50.0% nodiag /3 eclipse 50.0% 0.01s 100.0% Out = [1, 3, 6, 8, 2, 4, 9, 7, 5] Yes (0.14s cpu)
profile/1
predicate itself always succeeds.
Goal:
shows the goal which was
profiled.
Note that, when compiled, the abovequeen_100 :- (for(_,1,100,1) do queen([1,2,3,4,5,6,7,8,9],_Out)).
do/2
loop would be
efficiently implemented and not cause overhead that would distort the
measurement. Section 5.2 presents a
detailed description of logical loops.
In the above example, the profiler takes over three hundred samples resulting in a more accurate view of where the time is being spent in the program. In this instance we can see that more than half of the time is spent in the?- profile(queen_100). goal succeeded PROFILING STATISTICS -------------------- Goal: queen_100 Total user time: 3.19s Predicate Module %Time Time %Cum -------------------------------------------------------- nodiag /3 eclipse 52.2% 1.67s 52.2% qdelete /4 eclipse 27.4% 0.87s 79.6% qperm /2 eclipse 17.0% 0.54s 96.5% safe /1 eclipse 2.8% 0.09s 99.4% queen /2 eclipse 0.6% 0.02s 100.0% Yes (3.33s cpu)
nodiag/3
predicate, making it an ideal
candidate for optimisation. This is left as an exercise for the
reader.