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

Fast SIGNUM equivalent



Jeff, 

I dont claim to be an expert on the LISPM but i got interested in your
problem and i tryed an example on my Mac Ivory model 3. Here is what I
got, hope its helpful:

(defun test (i1 i2)
  (CASE (SIGNUM (- I1 I2))
    (1 'a)
    (0 'b)
    (-1 'c)))

(defun test1 (i1 i2)
  (let ((a (- I1 I2)))
    (cond
      ((plusp a) 'a)
      ((minusp a) 'b)
      (t 'c))))


(defun testa ()
  (time (dotimes (x 1000000) (test 45 56)))
  (time (dotimes (x 1000000) (test1 45 56))))

  (testa)

Evaluation of (DOTIMES (X 1000000)
                (TEST 45 56)) took 3.629644 seconds of elapsed time including:
  0.011 seconds processing sequence breaks,
  0.001 seconds in the storage system (including 0.000 seconds waiting for pages):
    0.000 seconds processing 0 page faults including 0 fetches,
    0.001 seconds in creating and destroying pages, and
    0.000 seconds in miscellaneous storage system tasks.

214 list, 513 structure words consed in WORKING-STORAGE-AREA.
Evaluation of (DOTIMES (X 1000000)
                (TEST1 45 56)) took 1.835009 seconds of elapsed time including:
  0.007 seconds processing sequence breaks,
  0.000 seconds in the storage system (including 0.000 seconds waiting for pages):
    0.000 seconds processing 0 page faults including 0 fetches,
    0.000 seconds in creating and destroying pages, and
    0.000 seconds in miscellaneous storage system tasks.


--------------------------------------------------------------------------------
Martin Mallinson                                martin@cmt.dialnet.symbolics.com

Crimble Micro Test Inc.                              
5 Tomahawk Drive                                Phone: 508 667 9405
Billerica MA 01821                              Fax:   508 667 0192
--------------------------------------------------------------------------------