ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I have some scripts for which bash is too slow. I thought it would be a nice idea to try scsh for it. I just picked some lines from their manual, so I might be missing out on something, but to me it seems extremely slow.
I have tried to copy half a million empty files from one directory to the other.The first 20000 or so take 20 secs on my old PC to complete with bash.
With scsh it takes four times as long.
Using directory-strings and for-each, I just get the first 100,000 names, and the loop crashes at 20,000 or so, after 1 min 20 secs. An earlier test took ages, but at least got to 75000 files.
So I tried a straight loop like this:
(define (cpy f) (run (cp ,f "copies")))
(do ((it 0 (+ it 1))) ((> it 20000)) (cpy (string-append "file" (number->string it))))
This crashes at 20.000 as well.
(define (loop it itend)
(cond ((< it itend) (begin
(cpy (string-append "files" (number->string it)))
(loop (+ it 1) itend )
crashes after 500 files, even.
What am I doing wrong here ??
I have tried to copy half a million empty files from one directory to the other.
I wouldn't expect to see any performance difference with different shells for a task like this, since it seems likely that disk IO would be the bottleneck. However, since you are seeing a difference (and also crashing), my guess is you've hit a bug in scsh. Note that scsh hasn't seen a release since 2006, and I get the impression that it was always more of prototype/research project.
it seems likely that disk IO would be the bottleneck.
I hoped it would loop faster than the regular shell. I do not know anything about Python (that's why I tried scsh first), but I just picked some commands from their website to test it, instead of scsh. Comparing the following two loops, I think different scripting languages already loop faster than ksh/bash.
It must be that scheme shell is buggy. Pity, I had the impression it was something I would like.
while ((index < 100001)) ; do
(cat << EOT
for f in files:
EOT) > cpy.py
chmod u+x cpy.py
rm -rf copies
time for file in file* ; do
cp $file copies
Comparing the following two loops, I think different scripting languages already loop faster than ksh/bash.
Yes, shells are usually slow, plus you are invoking the cp program every iteration of the loop (the scsh loop has the same problem). Somehow I thought the overhead wouldn't be that significant, but upon reflection empty files could be cached pretty easily so the disk IO wouldn't be that bad. You could also accomplish this task without a loop: