This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

poor bash/sh while loop performance


I hadn't upgraded my cygwin installation for nine
months or so, and when I did, I started having a
peculiar performance problem with one of my shell
scripts.  When you pipe into a "while read xxx; do"
loop, it's very slow.  I wrote a little benchmark
shell script to help me validate this belief, and it's
attached.

When I time it with just a bunch of nested "for"
loops, I get the following results:
    # time ./doit 1

    real    0m2.544s
    user    0m0.000s
    sys     0m0.000s

When I time it by piping the nested "for" loops into a
"while read" loop, I get the following results:
    # time ./doit 2

    real    0m22.855s
    user    0m0.000s
    sys     0m0.000s

As you can see, the "while read" loop seems to have
pitiful performance.

I changed the first line to "#!/bin/bash" to make sure
it wasn't specific to sh as opposed to bash, with the
same results.

I ran the "bash" version of the same benchmark script
on a linux box (basically same version of bash), and
the time doubled between the two passes, which is
pretty much what you would expect, so this seems to be
something in cygwin, not specific to the shell.

Anybody have any idea what's wrong, and how it might
be fixed?

Thanks.

    -Russ

__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com

Attachment: doit
Description: doit

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]