Is there any way to do some benchmarking on several Prolog programs? I am using SWI-Prolog, and it doesn't show the time taken to execute the query!!
Asked
Active
Viewed 3,947 times
3 Answers
8
What about time/1
? In SWI-Prolog, try:
?- time(your_goal).
and
?- profile(your_goal).

Carles Araguz
- 1,157
- 1
- 17
- 37

mat
- 40,498
- 3
- 51
- 78
1
ok , found something useful .. predicate call_with_time_limit
meta_predicate time:call_with_time_limit(+,0).
time:call_with_time_limit(A, C) :-
A>0, !,
setup_call_cleanup(alarm(A, time_limit_exceeded(A), B, [install(false)]), run_alarm_goal(B, C), remove_alarm_notrace(B)).
time:call_with_time_limit(_, _) :-
throw(time_limit_exceeded).
you can define the time limit for the query, execute that on different queries and compare the number of result back within that time period, it is not that efficient but thats what i have found so far

AhmadAssaf
- 3,556
- 5
- 31
- 42
1
In GNU-Prolog time predicate can be taken from Prolog Compatibility Layers.
Referring to David Reitter's GNU Prolog compatibility layer :
%time
time(Goal) :-
cpu_time(CPU),
Goal,
cpu_time(CPU2),
CPUT is CPU2-CPU,
write('time: '), write(CPUT), write('ms.\n').
time(Text, Goal) :-
cpu_time(CPU),
Goal,
cpu_time(CPU2),
CPUT is CPU2-CPU,
write(Text), write(': '), write(CPUT), write('ms.\n').

Community
- 1
- 1

Grzegorz Wierzowiecki
- 10,545
- 9
- 50
- 88