Re: Why are intepreters so slow today

Lawrence G. Mayka (lgm@polaris.ih.att.com)
Thu, 21 Apr 1994 14:56:07 GMT

In article <LGM.94Apr21092807@polaris.ih.att.com> lgm@polaris.ih.att.com (Lawrence G. Mayka) writes:

main ()
{
int i;
double x = 0.0;
for (i = 0; i < 1000000; ++i)
x = x + 1.0;
return x;
}

The user time was 0.61 sec.

Oops, I forgot optimization. With '-O', this C program runs in 0.15
sec.

(defun my-float-loop-double ()
(declare (optimize (speed 3) (safety 0) (debug 0) (space 0)))
(do ((i 0 (the fixnum (1+ i)))
(x 0d0 (the double-float (+ 1d0 x))))
((>= i 1000000) x)
(declare (fixnum i) (double-float x))))

The user time was 0.23 sec. The Common Lisp code was close to three

A slight modification to this reduces the time on Allegro Common Lisp
to 0.15 sec, the same as the C version:

(defun my-float-loop-double-faster ()
(declare (optimize (speed 3) (safety 0) (debug 0) (space 0)))
(let ((y 1d0))
(declare (double-float y))
(do ((i 0 (the fixnum (1+ i)))
(x 0d0 (the double-float (+ y x))))
((>= i 1000000) x)
(declare (fixnum i) (double-float x)))))

--
        Lawrence G. Mayka
        AT&T Bell Laboratories
        lgm@ieain.att.com

Standard disclaimer.