1 |
On Tue, Oct 16, 2007 at 03:14:12AM +0100, Steve Long wrote: |
2 |
> Gilles Dartiguelongue wrote: |
3 |
> > I haven't reread the fine mans for a while but iirc, + could lead you to |
4 |
> > hit the argument buffer limit of your shell. xargs has --max-args to get |
5 |
> > around that and is also way faster than any -exec variant (at least |
6 |
> > that's what the bench I did on a PIV2.6Ghz showed me about 4 months ago) |
7 |
> > |
8 |
> It doesn't: find will just execute the command as many times as needed (each |
9 |
> time with an argument length maximally less than ARG_MAX. Well, it did when |
10 |
> we tested this a couple of months ago.) So it's optimal in that sense. I |
11 |
> have no idea on the timing measurements, but I don't like pipes and |
12 |
> subshells as a rule (externals are bad enough!;>) It'd be interesting to |
13 |
> see measurements over 100000 loops with long argument lists requiring |
14 |
> multiple invocations per pass, I suppose. |
15 |
|
16 |
Here's a quick benchmark: |
17 |
|
18 |
% \ |
19 |
repeat 3 \time find -name '*.ebuild' | xargs cat >/dev/null; echo; \ |
20 |
repeat 3 \time find -name '*.ebuild' -exec cat {} ';' >/dev/null; echo; \ |
21 |
repeat 3 \time find -name '*.ebuild' -exec cat {} '+' >/dev/null |
22 |
66.28 real 0.77 user 4.71 sys |
23 |
30.95 real 0.76 user 4.73 sys |
24 |
30.08 real 0.76 user 4.67 sys |
25 |
|
26 |
174.72 real 18.10 user 112.92 sys |
27 |
208.69 real 18.07 user 117.05 sys |
28 |
173.64 real 18.10 user 110.79 sys |
29 |
|
30 |
62.61 real 1.26 user 10.88 sys |
31 |
54.98 real 1.25 user 10.46 sys |
32 |
41.84 real 1.25 user 10.00 sys |
33 |
|
34 |
the third variant doesn't get any faster than on the last line. |
35 |
|
36 |
( tested in zsh, with bsd time and gnu find ) |
37 |
|
38 |
|
39 |
-- Elias |