On Fri, 2002-10-25 at 13:47, Brian Ashe wrote:
> Bret Hughes,
> 
> On Friday October 25, 2002 01:46, Bret Hughes wrote:
> > On Fri, 2002-10-25 at 12:07, Todd A. Jacobs wrote:
> > > On Fri, 25 Oct 2002, Robert P. J. Day wrote:
> > > > there is a handy command, "seq", which will generate sequences of
> > > > numbers that you can then plug into any command, as in
> > >
> > > Heh. With a little work, you can do that in bash without the command
> > > substitution:
> > >
> > >   LOOP=0
> > >   while [[ LOOP++ -lt 100 ]]; do mkdir $LOOP; done
> > >
> > > Handy to know if you have bash but not sh-utils installed.
> >
> > yep but apparently a lot slower. I figured that it would be quicker but
> > I guess calling mkdir 100 time as opposed to calling it once with may
> > args makes the difference.  The results of my quick and dirty tests:
> <snip>
> > [bhughes@bretsony bhughes]$ time mkdir $(seq 1 100)
> >
> > real        0m0.016s
> > user        0m0.000s
> > sys 0m0.020s
> <snip>
> > [bhughes@bretsony bhughes]$ time { LOOP=0;while [[ LOOP++ -lt 100 ]]; do
> > mkdir $LOOP;done }
> >
> > real        0m0.507s
> > user        0m0.150s
> > sys 0m0.240s
> <snip>
> > interesting I thought.
> 
> So you should eliminate the repetitive calls to mkdir with something like...
> 
> time { AR=" "; LOOP=0; while [[ LOOP++ -lt 100 ]]; do AR="$AR $LOOP"; done; 
> mkdir $AR; }
> 
> Do you want to see how that compares? It should be more competitive but still 
> a little slower.
> 
Yep.
I love orders of magnitude improvments

[bhughes@bretsony bhughes]$ time { AR=" "; LOOP=0; while [[ LOOP++ -lt
100 ]]; do AR="$AR $LOOP"; done; 
> mkdir $AR; }

real    0m0.019s
user    0m0.000s
sys     0m0.020s

Bret



-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@;redhat.com?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to