Re: Ann: SWI-Prolog 7.1.9
Jan Wielemaker <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <[email protected]> |
Hi Jos,
On 02/27/2014 12:38 AM, Jos De Roo wrote:
> Hi Jan,
>
> With the attached file graph.n3p we get
> $ swipl -f graph.n3p -g halt
> % graph.n3p compiled 2.21 sec, 100,103 clauses
>
> Compared to version 6.6.1 this is a speed drop of 38%
> $ swipl -f graph.n3p -g halt
> % graph.n3p compiled 1.60 sec, 100,103 clauses
The original file didn't make it to the list because of
the long attachment, but that doesn't matter too much.
Yes, compilation in 7.x is slower. This is because there
is more support for term/goal expansion/4, which includes
translation the source location information. The second
reason is that the functional notation support requires
analyzing the source in more depth.
If you want best speed for loading big Prolog data files,
load them using a read/assert loop and finally call
compile_predicates/1 to make the code static. So,
==
load_file(File, Module) :-
setup_call_cleanup(
open(File, read, In),
read_file(In, Module),
close(In)),
findall(Module:Name/Arity,
( predicate_property(Module:Head, dynamic),
functor(Head, Name, Arity)
), Preds),
compile_predicates(Preds).
read_file(In, Module) :-
read_term(In, T0, []),
read_file(T0, In, Module).
read_file(end_of_file, _, _) :- !.
read_file(Term, In, Module) :-
assert_clause(Term, Module),
read_term(In, T2, []),
read_file(T2, In, Module).
assert_clause((:-_), _) :- !.
assert_clause(Term, Module) :-
assertz(Module:Term).
==
1 ?- time(load_file('graph.n3p', test)).
% 401,925 inferences, 0.449 CPU in 0.449 seconds (100% CPU, 895476 Lips)
(vs. 1.5. seconds for consult). The time is now 92% read_term and 7%
assertz and 1% for the loop above.
And of course, there is the RDF database :-) Did you compare the
two in terms of loading time, storage space and query time?
Cheers --- Jan