dumb optimation problem
Made the following agorithm: (defmacro a= (val1 func) `(let ((it ,val1)) (= it (funcall ,func it)))) (defun lame-prime-check (p) (declare (fixnum p i) (optimize (safety 0) (fixnum-safety 0))) (cond ((< p 2) nil) ((a= (/ p 2) #'floor) nil) (t (loop for i from 3 to (isqrt p) by 2 do (when (a= (/ p i) #'floor) (return-from lame-prime-check nil))) t)) CAPI-TUTOR 97 > (time (loop for i from 0 to 1000000 do (lame-prime-check i))) Timing the evaluation of (LOOP FOR I FROM 0 TO 1000000 DO (LAME-PRIME-CHECK I)) User time = 19.656 System time = 0.000 Elapsed time = 19.719 Allocation = 428171796 bytes 0 Page faults Calls to %EVAL 15000061 NIL (Managed to save 11 s of the original version.) Why do I get the large allocation value? I suspect (/ p i) has something to do with it. Before the macro optimation the value was exactly double this. -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/