I only recently started playing with scsh, and re-wrote a Perl script
in it, to see how comfortable it was. The script was easy to write,
and worked, but took *much* longer than the original. I've since
simplified the script to a simple line-reading loop, and found that
the same code takes about 15 times longer with scsh than with Guile.
I'd like to know why there's such a difference. I hope that the
slowness is due to some confusion on my part, and isn't an inherent
quality of scsh, because if it is inherent, it will render scsh
unusable for many of the things I'd hoped to use it for.
Anyway, here's what I did: I put this into a file `scsh-test.scm':
(call-with-input-file "/tmp/x"
(lambda (port)
(let loop ((line (read-line port))
(lines-read 1))
(if (eof-object? line)
(format #t "Read ~A lines~%" lines-read)
(loop (read-line port)
(+ 1 lines-read))))))
and then at the shell
08:22:18 [erich@offby1 tmp]$ time guile -s scsh-test.scm
Read 1885 lines
real 0m0.416s
user 0m0.320s
sys 0m0.010s
08:22:22 [erich@offby1 tmp]$ time scsh -s scsh-test.scm
Read 1885 lines
real 0m6.339s
user 0m5.250s
sys 0m0.150s
Then I wondered if the slowness was due to scsh's famous startup time,
so I pasted the following into an already-running scsh:
(let ((start (time)))
(call-with-input-file "/tmp/x"
(lambda (port)
(let loop ((line (read-line port))
(lines-read 1))
(if (eof-object? line)
(format #t "Read ~A lines~%" lines-read)
(loop (read-line port)
(+ 1 lines-read))))))
(let ((stop (time)))
(format #t "Time: ~A seconds~%" (- stop start))))
I saw
Read 1885 lines
Time: 6 seconds
#f
which is essentially the same value as when I ran the standalone
script.
So: why on Earth is scsh so slow? Is there something I can do to
speed it up a lot, or do people just put up with the slowness?
(I'm aware that there's a "partial" port of scsh to guile, but I seem
to recall finding it difficult to get working.)
I doubt it matters, but the file "/tmp/x" was created like this:
$ find / -ls | head -1884 > /tmp/x
And here's a bit of info about my computer, on the chance that it's
relevant:
08:48:46 [erich@offby1 tmp]$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 5
model name : Pentium II (Deschutes)
stepping : 0
cpu MHz : 334.095
cache size : 512 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov
pat pse36 mmx fxsr
bogomips : 666.82
08:49:13 [erich@offby1 tmp]$ uname -a
Linux offby1 2.4.18crypto #1 Sat Nov 16 15:06:52 PST 2002 i686 unknown
08:49:15 [erich@offby1 tmp]$
--
In the practice of computing, where we have so much latitude for
making a mess of it, mathematical elegance is not a dispensable
luxury, but a matter of life and death.
-- Edsger W. Dijkstra: My Hopes of Computing Science (EWD 709)
http://www.cs.utexas.edu/users/EWD/ewd07xx/EWD709.PDF
|