Re: PIPs from the Basilisk Chamber (Was: 50 Years of Prolog Nonsense)

Liste des GroupesRevenir à cl prolog 
Sujet : Re: PIPs from the Basilisk Chamber (Was: 50 Years of Prolog Nonsense)
De : janburse (at) *nospam* fastmail.fm (Mild Shock)
Groupes : comp.lang.prolog
Date : 09. Nov 2024, 15:47:59
Autres entêtes
Message-ID : <vgnsmu$d3as$1@solani.org>
References : 1 2 3 4 5 6 7 8 9
User-Agent : Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0 SeaMonkey/2.53.19
I can speed it up, if I use nb_setarg/3 instead
of the explicit duplicate_term/2 and nb_linkarg/3 combo.
The change is as follows:
/* Before */
sys_find2_next(T, X) :-
    C = [_|_],
    duplicate_term(T, H),
    nb_linkarg(1, C, H),
    arg(1, X, J),
    nb_linkarg(2, J, C),
    nb_linkarg(1, X, C)
/* After */
sys_find2_next(T, X) :-
    C = [_|_],
    nb_setarg(1, C, T),
    arg(1, X, J),
    nb_linkarg(2, J, C),
    nb_linkarg(1, X, C).
Now the timings are better:
/* Before */
?- time(test2).
% 6,007,999 inferences, 0.422 CPU in 0.427
seconds (99% CPU, 14241183 Lips)
true.
/* After */
?- time(test2).
% 5,007,999 inferences, 0.297 CPU in 0.298
seconds (100% CPU, 16869049 Lips)
true.
A wooping more than 100 milliseconds are gone!

Date Sujet#  Auteur
29 Sep 24 * PIPs from the Basilisk Chamber (Was: 50 Years of Prolog Nonsense)7Mild Shock
8 Nov 24 +* Prolog Pearls I: Barklund and Millroth (Was: PIPs from the Basilisk Chamber)4Mild Shock
8 Nov 24 i`* Prolog Pearls II: Barklund and Millroth (Was: PIPs from the Basilisk Chamber)3Mild Shock
8 Nov 24 i `* change_arg/3 = nb_linkarg/3 ? (Was: PIPs from the Basilisk Chamber)2Mild Shock
8 Nov 24 i  `- Re: change_arg/3 = nb_linkarg/3 ? (Was: PIPs from the Basilisk Chamber)1Mild Shock
9 Nov 24 `* Re: PIPs from the Basilisk Chamber (Was: 50 Years of Prolog Nonsense)2Mild Shock
9 Nov 24  `- Re: PIPs from the Basilisk Chamber (Was: 50 Years of Prolog Nonsense)1Mild Shock

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal