[Openmcl-devel] It's too long to take in READ-LINE !
R. Matthew Emerson
rme at clozure.com
Wed Jan 18 11:46:34 PST 2012
On Jan 18, 2012, at 7:43 AM, Xiaofeng Yang wrote:
> I created a simple file with just full of spaces and has size 1MB. Then I opened it and read it using READ-LINE. It takes more than 1 minutes !!!
>
> CL-USER> (lisp-implementation-type)
> "Clozure Common Lisp"
> CL-USER> (lisp-implementation-version)
> "Version 1.8-dev-r14962-trunk (WindowsX8632)"
>
> The time I took in READ-LINE:
> (READ-LINE F NIL) took 67,439 milliseconds (67.439 seconds) to run
> with 8 available CPU cores.
> During that period, 63,391 milliseconds (63.391 seconds) were spent in user mode
> 2,921 milliseconds (2.921 seconds) were spent in system mode
> 23,977 milliseconds (23.977 seconds) was spent in GC.
> 17,185,637,938 bytes of memory allocated.
That does sound horrible, but I'm not seeing that result on my system.
I used this code:
(in-package "CL-USER")
(defun make-spaces-file (pathname)
(with-open-file (s pathname :direction :output :if-exists :supersede
:if-does-not-exist :create
:external-format :utf-8)
(let ((spaces (make-string 1024 :initial-element #\space
:element-type 'character)))
(dotimes (i 1024)
(write-sequence spaces s)))))
(defun read-spaces-line (pathname)
(let ((line nil))
(with-open-file (s pathname :external-format :utf-8)
(setq line (read-line s nil nil)))
(format t "~&read line of ~d characters" (length line))))
And got these results:
CL-USER> (make-spaces-file "spaces")
NIL
CL-USER> (time (read-spaces-line "spaces"))
read line of 1048576 characters
(READ-SPACES-LINE "spaces") took 234 milliseconds (0.234 seconds) to run
with 1 available CPU core.
During that period, 141 milliseconds (0.141 seconds) were spent in user mode
63 milliseconds (0.063 seconds) were spent in system mode
62 milliseconds (0.062 seconds) was spent in GC.
14,681,920 bytes of memory allocated.
NIL
CL-USER>
This was a Windows XP system running under VMware.
More information about the Openmcl-devel
mailing list