I don't understand why touch is the right thing, it doesn't create directories either, just files. Care to explain why did you chose touch instead of ">"?
Using the external binary touch to create 10000 files:
samueloph@teste:~/foo$ time ( for i in $(seq 0 9999) ; do touch $i ; done ) real 0m10.245s user 0m3.332s sys 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.742s user 0m0.064s sys 0m0.120s
">" is at least 10x faster than touch.
But anyways, OP asked for 5000 directories, not files, shouldn't the tests be made with mkdir instead of touch or ">"?
Not a big deal tough.
Samuel Henrique O. P. [samueloph] Técnico em Informática - UTFPR [2012]. Estudante de Engenharia de Computação - UTFPR.