On Sun, Aug 10, 2003 at 01:51:10PM -0600, LuKreme wrote:
On Sunday, 10 August 2003, at 12:24, Dallman Ross wrote:
KrispyKream is wrong to say that the -ls option to find is more
efficient; it is not. Options to find are executed once per
each file found. Otoh, a pipe to xargs runs the ls command one
time only, on all arguments found. More efficient, by orders of
magnitude!
| xargs opens a whole other pipe. -ls does not. One process vs.
multiple processes. I was taught that one process is better.
Using -ls does appear to be FASTER and doesn't care about spaces in
the path.
No, it's not faster. Don't succumb to cargo-cult mentality. Think
about what the binary is doing, and about what I said the first time.
`Find' is descending through the directory structure and finding
files. Each time it finds a file, it runs its internal version lf
ls (-l) on that file. If there are a million files, `find' will
run its internal ls a million times.
The piped `ls', though, can take multiple arguments. (Probably
not a million, though, I'll admit.) So while it is adding a
pipe, it is gaining that cost back and more by only running
once.
Your "appears to take longer" statement I suspect has to do with
what you see with the start of the process, with your eyeballs.
Certainly without the pipe, you see find's `ls' output starting
already with the very first file. Meanwhile, find is continuing
to process all files. The pipe requires you to wait for all
files' having been found before any are displayed.
Run `time' on the whole thing. I did it with my $HOME tree
alone, and (after running each command a few times to optimize
local caching) I got about 18 seconds for
time find ~ -ls
versus about 14 seconds for
time ls -ld `find ~`
--
dman
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail