[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: 5000 Folders in a directory



> *samueloph@teste:~/foo$ time ( for i in $(seq 0 9999) ; do touch $i ; done
> )real    0m10.245suser    0m3.332ssys    0m1.576s*
> Using shell built-in ">" to create 10000 files:
​>
> *samueloph@teste:~/foo$ time ( for i in $(seq 0 9999) ; do > $i ; done
> )real    0m0.742suser    0m0.064ssys    0m0.120s​*
>
> ​">" is at least 10x faster than touch.​

Your spirit of healthy scepticism is admirable but what these
tests compare is not so much the time it takes to create a file
with ">" vs touch(1) than the time it takes to create a process
relative to the time it takes for the shell to iterate through
a for() loop.

Try "seq 0 9999 | xargs touch" (3 process creations instead of
10,001). It will almost certainly be even faster than the ">"
version.


Reply to: