new comer. performance question

Featuring the Dragonfly web framework

new comer. performance question

Postby fetchoo » Mon Jan 13, 2014 4:34 pm

Hi

I tried the following and compared the running time with CCL

> (let ((s)) (time (dotimes (i 1000000) (set 's (cons (sqrt i) s)))))
... do not stop
> (let ((s)) (time (dotimes (i 1000000) (push (sqrt i) s))))
111.93 milliseconds

with CCL
? (let ((s)) (time (dotimes (i 100000) (push (sqrt i) s))))
848 milliseconds

in CCL (setq x (cons a x)) == (push a x), but it looks like it is not the case for newlisp (i tried set/setf/setq)

why is this? how set/setq/setf/cons are implemented?

Kind regards
Taoufik
fetchoo
 
Posts: 1
Joined: Mon Jan 13, 2014 4:24 pm

Re: new comer. performance question

Postby Lutz » Mon Jan 13, 2014 5:41 pm

In newLISP cons creates a new list which then in you example is placed into s.

push takes the reference of s and modifies s which is muchfaster because no list creation and copying takes place.
Lutz
 
Posts: 5258
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California


Return to So, what can you actually DO with newLISP?

Who is online

Users browsing this forum: No registered users and 2 guests