# Fixnum Declarations

```Perhaps not everyone is aware of just how important for speed it is to
declare arithmetic to be fixnum in KCL/AKCL when you can.  So here are
some figures that show that you can get more than a factor of 10
speedup with the right declarations.

I have tried to be careful with these timings and have done them
several times but you shouldn't draw any conclusions from them except
that you should think about putting in declarations when you're doing
fixnum arithmetic in AKCL/KCL and speed is important.  The
manufacturers of various Lisps know a variety of ways to measure more
accurately than a user who types TIME to a time-sharing system does,
particularly on short little runs like these.  Furthermore, I am far
from expert at using Lucid or Allegro, so I can imagine that
additional declarations might give better times for those Lisps.  This
might even be true for AKCL/KCL!

------------------------------------------------------------
------------------------------------------------------------

Some fib times comparing AKCL, Lucid/Sun, and Allegro, all compiled
with Safety 0, Speed 3.  Times in seconds for a call of (fib 29).
Times as reported by the built-in TIME function of Lisp.

------------------------------------------------------------

No fixnum declarations.

(defun fib(n) (if (< n 2) n (+ (fib (- n 1)) (fib (- n 2)))))

79   AKCL 1.57 on a Sun-3/280
25.9 AKCL 1.79 on a Sun-4/280
12.1 Allegro 3.1 on a Sun-3/280
10.3 Sun/Lucid 3.0 on a Sun-3/280
3.8  Sun/Lucid 2.1 on a Sun-4/280

------------------------------------------------------------

Lots of fixnum declarations.

(proclaim '(function fib (fixnum) fixnum))

(defun fib (n)
(declare (fixnum n))
(if (< n 2) n (the fixnum (+ (fib (the fixnum (- n 1)))
(fib (the fixnum (- n 2)))))))

9.0  Allegro 3.1 Sun-3/280
7.0  Sun/Lucid 3.0 on a Sun-3/280.
6.5  ACKL 1.57 on a Sun-3/280.
2.81 Lucid 2.1 on a Sun-4/280.
2.18 AKCL 1.79 on a Sun-4/280.

------------------------------------------------------------

When putting in declarations for arithmetic or array references, I
find it handy to use DISASSMBLE to look at the C to see whether I need
to put in more or different declarations.

Allegro CL is a registered trademark of Franz, Inc.  Lucid is a
registered trademark of Lucid, Inc.  Sun has an infinite number of
trademarks of the form ``Sun-n,'' where n is numeric.  This raises an
interesting legal issue, since it means that ``Sun'' followed by the
binary for OS360 is a Sun trademark.

```