On Tue, Oct 16, 2007 at 03:14:12AM +0100, Steve Long wrote:
> Gilles Dartiguelongue wrote:
> > I haven't reread the fine mans for a while but iirc, + could lead you to
> > hit the argument buffer limit of your shell. xargs has --max-args to get
> > around that and is also way faster than any -exec variant (at least
> > that's what the bench I did on a PIV2.6Ghz showed me about 4 months ago)
> > 
> It doesn't: find will just execute the command as many times as needed (each
> time with an argument length maximally less than ARG_MAX. Well, it did when
> we tested this a couple of months ago.) So it's optimal in that sense. I
> have no idea on the timing measurements, but I don't like pipes and
> subshells as a rule (externals are bad enough!;>) It'd be interesting to
> see measurements over 100000 loops with long argument lists requiring
> multiple invocations per pass, I suppose.

Here's a quick benchmark:

% \
  repeat 3 \time find -name '*.ebuild' | xargs cat >/dev/null; echo; \
  repeat 3 \time find -name '*.ebuild' -exec cat {} ';' >/dev/null; echo; \
  repeat 3 \time find -name '*.ebuild' -exec cat {} '+' >/dev/null
       66.28 real         0.77 user         4.71 sys
       30.95 real         0.76 user         4.73 sys
       30.08 real         0.76 user         4.67 sys

      174.72 real        18.10 user       112.92 sys
      208.69 real        18.07 user       117.05 sys
      173.64 real        18.10 user       110.79 sys

       62.61 real         1.26 user        10.88 sys
       54.98 real         1.25 user        10.46 sys
       41.84 real         1.25 user        10.00 sys

the third variant doesn't get any faster than on the last line.

( tested in zsh, with bsd time and gnu find )


-- Elias

Attachment: pgpUglx1YKVOi.pgp
Description: PGP signature

Reply via email to