Randall R Schulz wrote:
Danny,
On Friday 21 January 2005 09:49, Danny Sauer wrote:
...
It's essentially the same code in find (function launch in pred.c). Then, why is xargs faster?
Oh, wait, looking closer... It appears that xargs builds a commandline up until the maximum length on a system, and then runs that. I always thought that xargs ran a new instance of the exec()'d program for each individual argument. Hmph. I guess that'd explain why it takes 8-10 seconds to do all 2642 files in the samba3 source dir (which was convenient at the time) using -exec, while it only takes about 2 seconds to do the same thing with xargs.
The -exec method is more flexible, though, and will work with programs that only accept one file as an arg, etc. I guess it's just a matter of choosing the right tool for the job, and sinc -exec always works, I tend to go that way. It's easier to remember one thing than 2. :)
True enough. But another thing to keep in mind, at least in general, is that not all systems that support the Gnu tools (find and xargs, e.g.) implement copy-on-write fork semantics. On such systems the performance disparity between the -exec and xargs approaches is far greater than what you'd experience on a Linux system. Cygwin is such a Gnu tools platform, e.g.
--Danny, who learned something today
So... It's a _good_ day, right?
Randall Schulz
Of course, yes ;) -- Laurent Renard