[Prev][Next][Index][Thread]

Re: Dylan performance



Rolf Wester <wester@ilt.fhg.de> writes:

> I'm a Dylan newby and try to test Dylan's performance. I'm running FO
> Dylan on a 450 MHz Pentium II with 520 MB RAM.
> The small test program is listed below. The Dylan version takes about 50
> seconds on my machine. A c++ version of that program takes only 0.2
> seconds (cygwin g++), a Python version 25 seconds and ACL6.0 Lisp 9
========================================================^^^^^^^^^^^^^
> seconds (with all possible declarations; CMUCL is faster but only
==^^^^^^^
> available for UNIX). Is there any means to make the dylan code faster?

I know this is not a lisp forum, so I'll be brief.  I have sent email
with a longer explanation.  The code you posted had a bug in it which
gives the slow result you see, and it also had a lot of declarations
that were simply not necessary.

 [much code snipped ...]

 [CL version snipped ...]

> I find this almost unreadable

I agree, it was ugly code.  Maybe this version looks cleaner:

(defun temp-diff (nt)
  (declare (optimize (speed 3) (safety 0) (debug 0)))
  (let ((mat1 (make-array '(300 300) :element-type 'single-float
			  :initial-element 0.0))
	(mat2 (make-array '(300 300) :element-type 'single-float
			  :initial-element 0.0)))
    (declare (type (simple-array single-float (300 300)) mat1))
    (declare (type (simple-array single-float (300 300)) mat2))
    
    (dotimes (k nt)
      (declare (type fixnum k nt))
      (loop for i fixnum from 1 to 298 do
	    (loop for j fixnum from 1 to 298 do
		  (setf (aref mat2 i j)
		    (+ (aref mat1 i j) 1.0
		       (* 0.1
			  (+ (aref mat1 (+ i -1) j)
			     (* -4.0 (aref mat1 i j))
			     (aref mat1 (+ i 1) j)
			     (aref mat1 i (+ j -1))
			     (aref mat1 i (+ j 1))))))))
      (loop for i fixnum from 1 to 298 do
	    (loop for j fixnum from 1 to 298 do
		  (setf (aref mat1 i j)
		    (+ (aref mat2 i j) 1.0
		       (* 0.1 (+ (aref mat2 (+ i -1) j)
				 (* -4.0 (aref mat2 i j))
				 (aref mat2 (+ i 1) j)
				 (aref mat2 i (+ j -1))
				 (aref mat2 i (+ j 1))))))))

      (print (aref mat1 150 150))))))


-- 
Duane Rettig          Franz Inc.            http://www.franz.com/ (www)
1995 University Ave Suite 275  Berkeley, CA 94704
Phone: (510) 548-3600; FAX: (510) 548-8253   duane@Franz.COM (internet)



References: