I'm not really sure how could I adapt your command to use '>' instead of
touch, but shouldn't '>' be faster if using 3 processes too?

I mean, comparing one single execution of touch with ">", ">" is faster.
Thanks for the answer people, Tomas is right about the touch process.

Samuel Henrique O. P. [samueloph]
Técnico em Informática - UTFPR [2012].
Estudante de Engenharia de Computação - UTFPR.

2016-02-18 16:05 GMT-02:00 Jean-Baptiste Thomas <cau2jeaf1ho...@laposte.net>
:

> > *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 via email to