Sujet : KISS principle pays off (Was: A FFI for evaluable functions)
De : janburse (at) *nospam* fastmail.fm (Mild Shock)
Groupes : comp.lang.prologDate : 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.