KISS principle pays off (Was: A FFI for evaluable functions)

Liste des GroupesRevenir à cl prolog 
Sujet : KISS principle pays off (Was: A FFI for evaluable functions)
De : janburse (at) *nospam* fastmail.fm (Mild Shock)
Groupes : comp.lang.prolog
Date : 03. Nov 2024, 00:52:30
Autres entêtes
Message-ID : <vg6dvt$38jd$1@solani.org>
References : 1 2 3
User-Agent : Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0 SeaMonkey/2.53.19
I have dropped the idea to realize and use variant/2.
The idea is to use only numbervars/3. Here is a test,
testing the newest release of SWI-Prolog as well:
/* SWI-Prolog 9.3.14 */
?- time(test5).
% 39,918,731 inferences, 9.031 CPU in 9.022 seconds (100% CPU, 4420067 Lips)
true.
/* Dogelog Player 1.2.4 */
?- time(test5).
% Zeit 5696 ms, GC 0 ms, Lips 10186409, Uhr 03.11.2024 00:44
true.
The test code is:
test5 :-
    (between(1,1000,_),
       aggregate_all(count, distinct(gen3(_)), _),
       fail; true).
gen3(X) :-
    length(L, 25),
    between(1,1000,_),
    random(Y),
    Z is floor(Y*1000),
    X = [Z|L].

Ok, I tried a native implementation of variant/2.
I did it in Dogelog Player for Java. Thats a
Prolog system that doesn't have unification for
 cyclic terms. So the situation is a little simpler.
Comparing on the same machine and with the data
we have already gathered it is shockingly fast!
 /* Dogelog Player 1.2.4, JDK 22 */
 ?- time(test).
% Zeit 211 ms, GC 0 ms, Lips 7567459, Uhr 15.10.2024 01:30
true.
 ?- time(test2).
% Zeit 413 ms, GC 0 ms, Lips 10703217, Uhr 15.10.2024 01:30
true.
 
Here some results:
>
- SWI-Prolog 9.3.11:
>
?- time(test).
% 2,126,498 inferences, 0.734 CPU in 0.752 seconds
(98% CPU, 2895657 Lips)
true.
>
?- time(test2).
% 2,159,795 inferences, 0.234 CPU in 0.236 seconds
(99% CPU, 9215125 Lips)
true.

Date Sujet#  Auteur
9 Oct 24 * A FFI for evaluable functions7Mild Shock
9 Oct 24 +* Name resolution is a blackbox (Re: A FFI for evaluable functions)5Mild Shock
9 Oct 24 i`* plonk in discourse (Was: The issue with free speech)4Mild Shock
14 Oct 24 i `* When do two Prolog terms marry? (Was: The issue with free speech)3Mild Shock
14 Oct 24 i  +- Re: When do two Prolog terms marry? (Was: The issue with free speech)1Mild Shock
15 Oct 24 i  `- native implementation of variant/2 can be fast (Was: When do two Prolog terms marry?)1Mild Shock
3 Nov 24 `- KISS principle pays off (Was: A FFI for evaluable functions)1Mild Shock

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal