home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.lisp
- Path: sparky!uunet!psinntp!cmcl2!maya.CS.nyu.EDU!marcoxa
- From: marcoxa@maya.CS.nyu.EDU (Marco Antoniotti)
- Subject: CL I/O performance (Was: Playing sparcaudio directly from lisp)
- Message-ID: <9301081511.AA19973@maya.cs.nyu.edu>
- Sender: daemon@cmcl2.nyu.edu (Mr Background)
- Organization: New York University
- Date: Fri, 8 Jan 1993 05:11:02 GMT
- Lines: 76
-
- '(Good morning)
-
- In article <C0IEG8.G5n.1@cs.cmu.edu> mkant+@cs.cmu.edu (Mark Kantrowitz) writes:
-
- From: mkant+@cs.cmu.edu (Mark Kantrowitz)
- Newsgroups: comp.lang.lisp
- Keywords: Lucid sparcaudio
- Date: 8 Jan 93 00:24:04 GMT
- References: <1993Jan7.210217.21559@cs.cornell.edu>
- Sender: news@cs.cmu.edu (Usenet News System)
- Organization: School of Computer Science, Carnegie Mellon
- Lines: 163
- Nntp-Posting-Host: glinda.oz.cs.cmu.edu
-
- In article <1993Jan7.210217.21559@cs.cornell.edu> raman@cs.cornell.edu (T. V. Raman) writes:
- >I plan to start using sparc audio extensively inside a clos program,
-
- I wrote the following code for Allegro CL. As you can see by
- experimentation with the code and variations on it, playing the sound
- files from Lisp is much too slow. Lisp file IO just isn't fast enough.
- If you're going to play sound files, you'll have to do much of the
- work in C, and then use a foreign function interface to run the code.
-
- This is an interesting remark. I ran through the code and I sincerely
- do not understand why a Lisp application should be "slower" doing
- IO than a C/C++ application.
-
- As far as my experience is concerned the only "slow" call is the 'elt'
- in read-ascii-string. The functions do not seem to cons a lot.
-
- (defun read-ascii-string (file-stream num-bytes)
- (let ((result (make-string num-bytes)))
- (dotimes (i num-bytes)
- (setf (elt result i) (code-char (read-byte file-stream))))
- (string-right-trim (list (code-char 0)) result)))
-
- (defun read-32-bit-integer (file-stream)
- (let ((result 0))
- (dotimes (i 4)
- (setf result (ash result 8))
- (incf result (read-byte file-stream)))
- result))
-
- ;;; (...)
-
- (defun play-sounds (&optional (sounds '("AA" "r"))
- &key (blocked nil)
- (sound-dir *phoneme-directory*)
- (audio-dev "/dev/audio"))
- (cond (blocked
- (with-open-file (out *temp-sound-file*
- :direction :output
- :if-exists :supersede
- :if-does-not-exist :create
- :element-type 'unsigned-byte)
- (write-sounds sounds sound-dir out))
- (excl:run-shell-command (format nil "cat ~a > ~a"
- *temp-sound-file* audio-dev)))
- (t
- (with-open-file (out audio-dev
- :direction :output
- :if-exists :overwrite
- :element-type 'unsigned-byte)
- (write-sounds sounds sound-dir out)))))
-
-
- Here is my question. Are there any benchmarks around for I/O done in
- CL vs. the usual foes (i.e. C/C++)? I believe this would be another
- valuable piece of information regarding CL implementations.
-
- Thanks for your time,
- have a nice day
-
- Marco
-
-
-