[Openmcl-devel] consing iterating through a loop
Cyrus Harmon
ch-openmcl at bobobeach.com
Wed Jan 26 17:01:47 PST 2005
I'm trying to avoid allocating memory as I go through the loop. Here's
my code and problem:
(flet ((foo ()
(declare (optimize (speed 3) (safety 0) (space 0)))
(let ((z 2.0d0) (a 0d0))
(declare (double-float z)
(double-float a))
(dotimes (i 500000)
(declare (fixnum i))
(setf (the double-float a)
(the double-float (+ (the double-float a) (the double-float
z)))))
a
(time (foo)))
In OpenMCL:
(FOO) took 760 milliseconds (0.760 seconds) to run.
Of that, 150 milliseconds (0.150 seconds) were spent in user mode
50 milliseconds (0.050 seconds) were spent in system mode
560 milliseconds (0.560 seconds) were spent executing other OS
processes.
361 milliseconds (0.361 seconds) was spent in GC.
8,000,000 bytes of memory allocated.
1000000.0D0
In SBCL:
; in: LAMBDA NIL
; (THE DOUBLE-FLOAT A)
; ==>
; A
;
; note: doing float to pointer coercion (cost 13) from A
; compilation unit finished
; printed 1 note
Evaluation took:
0.002 seconds of real time
0.0 seconds of user run time
0.0 seconds of system run time
0 page faults and
96 bytes consed.
1000000.0d0
Any easy way to fix this?
Thanks,
Cyrus
More information about the Openmcl-devel
mailing list