home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / lisp / 3207 < prev    next >
Encoding:
Text File  |  1993-01-08  |  2.9 KB  |  87 lines

  1. Newsgroups: comp.lang.lisp
  2. Path: sparky!uunet!psinntp!cmcl2!maya.CS.nyu.EDU!marcoxa
  3. From: marcoxa@maya.CS.nyu.EDU (Marco Antoniotti)
  4. Subject: CL I/O performance (Was: Playing sparcaudio directly from lisp)
  5. Message-ID: <9301081511.AA19973@maya.cs.nyu.edu>
  6. Sender: daemon@cmcl2.nyu.edu (Mr Background)
  7. Organization: New York University
  8. Date: Fri, 8 Jan 1993 05:11:02 GMT
  9. Lines: 76
  10.  
  11. '(Good morning)
  12.  
  13. In article <C0IEG8.G5n.1@cs.cmu.edu> mkant+@cs.cmu.edu (Mark Kantrowitz) writes:
  14.  
  15.    From: mkant+@cs.cmu.edu (Mark Kantrowitz)
  16.    Newsgroups: comp.lang.lisp
  17.    Keywords: Lucid sparcaudio
  18.    Date: 8 Jan 93 00:24:04 GMT
  19.    References: <1993Jan7.210217.21559@cs.cornell.edu>
  20.    Sender: news@cs.cmu.edu (Usenet News System)
  21.    Organization: School of Computer Science, Carnegie Mellon
  22.    Lines: 163
  23.    Nntp-Posting-Host: glinda.oz.cs.cmu.edu
  24.  
  25.    In article <1993Jan7.210217.21559@cs.cornell.edu> raman@cs.cornell.edu (T. V. Raman) writes:
  26.    >I plan to start using sparc audio extensively inside a clos program,
  27.  
  28.    I wrote the following code for Allegro CL. As you can see by
  29.    experimentation with the code and variations on it, playing the sound
  30.    files from Lisp is much too slow. Lisp file IO just isn't fast enough.
  31.    If you're going to play sound files, you'll have to do much of the
  32.    work in C, and then use a foreign function interface to run the code. 
  33.  
  34. This is an interesting remark. I ran through the code and I sincerely
  35. do not understand why a Lisp application should be "slower" doing
  36. IO than a C/C++ application.
  37.  
  38. As far as my experience is concerned the only "slow" call is the 'elt'
  39. in read-ascii-string. The functions do not seem to cons a lot.
  40.  
  41.    (defun read-ascii-string (file-stream num-bytes)
  42.      (let ((result (make-string num-bytes)))
  43.        (dotimes (i num-bytes)
  44.      (setf (elt result i) (code-char (read-byte file-stream))))
  45.        (string-right-trim (list (code-char 0)) result)))
  46.  
  47.    (defun read-32-bit-integer (file-stream)
  48.      (let ((result 0))
  49.        (dotimes (i 4)
  50.      (setf result (ash result 8))
  51.      (incf result (read-byte file-stream)))
  52.        result))
  53.  
  54.    ;;; (...)
  55.  
  56.    (defun play-sounds (&optional (sounds '("AA" "r"))
  57.                  &key (blocked nil)
  58.                  (sound-dir *phoneme-directory*)
  59.                  (audio-dev "/dev/audio"))
  60.      (cond (blocked
  61.         (with-open-file (out *temp-sound-file*
  62.                  :direction :output
  63.                  :if-exists :supersede
  64.                  :if-does-not-exist :create
  65.                  :element-type 'unsigned-byte)
  66.           (write-sounds sounds sound-dir out))
  67.         (excl:run-shell-command (format nil "cat ~a > ~a" 
  68.                         *temp-sound-file* audio-dev)))
  69.        (t
  70.         (with-open-file (out audio-dev
  71.                  :direction :output
  72.                  :if-exists :overwrite
  73.                  :element-type 'unsigned-byte)
  74.           (write-sounds sounds sound-dir out)))))
  75.  
  76.  
  77. Here is my question. Are there any benchmarks around for I/O done in
  78. CL vs. the usual foes (i.e. C/C++)? I believe this would be another
  79. valuable piece of information regarding CL implementations.
  80.  
  81. Thanks for your time,
  82. have a nice day
  83.  
  84. Marco
  85.  
  86.  
  87.