home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / usr.bin / lisp / lispnews / text0335.txt < prev    next >
Encoding:
Text File  |  1985-11-10  |  1.9 KB  |  51 lines

  1.     A number of articles in recent IEEE Spectra have discussed Silicon
  2. Compilation in Prolog, and concluded with a statement to the effect: for
  3. performance reasons, we will go to Lisp for a production version.
  4.  
  5.     Is Lisp really faster than Prolog?  I used to think so.  Some time
  6. ago, I wrote a Prolog interpreter in Lisp: after several versions, I gave
  7. up, because I couldn't make my Prolog fast.  Its best speed was 100 LIPS
  8. through the append loop on a 780, or about 7% of the speed of C-Prolog (1500
  9. LIPS, according to the literature.
  10.  
  11.     Then it occured to me that I could not expect my Prolog to run
  12. faster than an equivalent function coded in Lisp.  I coded the function, and
  13. the result was the following:
  14.  
  15. (def my-append
  16.    (lambda (x y)
  17.       (cond (x (cons (car x) (my-append (cdr x) y)))
  18.         (t y))))
  19.  
  20. it can be seen that the time of the computation is invariant with respect to
  21. the second argument.  Hence, for all the tests to be mentioned, the second
  22. argument is '(1 2 3 4 5).
  23.  
  24.     I ran the program on the lists consisting of the first 100, 250, and
  25. 300 integers.  The results were the following:
  26.  
  27. list length    ticks (60/sec)    LIPS equivalent
  28.   100          14          429
  29.   250          29          517
  30.   300          34          529
  31.  
  32. Or about one-third the published speed of of the same function in CProlog on
  33. a 780.  I then wondered how the native Franz append would do.  This function
  34. is compiled, and is optimized for tail recursion, so the experiment is not
  35. really fair to CProlog.  In any case:
  36.  
  37. list length    ticks        LIPS equivalent
  38.   100          3          2000
  39.   250          8          1875
  40.   300         10          1800
  41.  
  42. I don't know what this proves, but I know what it doesn't prove.  The Lisp
  43. used, by the way, was Franz version 38.96 on a Vax 11/780 at the University
  44. of California at Berkeley.  Despite numerous queries to Edinburgh, we still
  45. don't have a version of C-Prolog for comparative measurement here, so I
  46. can't personally vouch for the 1500 LIPS claim.
  47.  
  48.                             Rick.
  49.  
  50.  
  51.