[illumos-Developer] webrev: 650 grep support for -q would be useful
Yuri Pankov
yuri.pankov at gmail.com
Tue May 3 10:35:24 PDT 2011
On Tue, May 03, 2011 at 08:47:26PM +0400, Yuri Pankov wrote:
> ----------------------------------------------------------------
> Bad performance when given a lot of files:
> ----------------------------------------------------------------
> GNU grep:
> $ time for i in `seq 1 100`; do /usr/gnu/bin/grep -q switch \
> ~/src/illumos/illumos-gate/usr/src/uts/common/io/*; done
>
> real 0m2.621s
> user 0m1.773s
> sys 0m0.841s
>
> BSD grep:
> $ time for i in `seq 1 100`; do ~/ws/650-grep-q/usr/src/cmd/grep/grep -q \
> switch ~/src/illumos/illumos-gate/usr/src/uts/common/io/*; done
>
> real 0m11.620s
> user 0m7.491s
> sys 0m4.176s
> ----------------------------------------------------------------
>
> ----------------------------------------------------------------
> Same (actually much worse) for -R/-r:
> ----------------------------------------------------------------
> GNU grep:
> $ time for i in `seq 1 100`; do /usr/gnu/bin/grep -rq switch \
> ~/src/illumos/illumos-gate/usr/src/uts/common/io/; done
>
> real 0m0.870s
> user 0m0.209s
> sys 0m0.642s
>
> BSD grep:
> $ time for i in `seq 1 100`; do ~/ws/650-grep-q/usr/src/cmd/grep/grep
> -rq switch ~/src/illumos/illumos-gate/usr/src/uts/common/io/; done
>
> real 2m34.742s
> user 1m48.919s
> sys 0m45.556s
> ----------------------------------------------------------------
INCORRECT. GNU grep seems to cheat when given -q (BSD grep could do the
same though):
----------------------------------------------------------------
Lot of files:
----------------------------------------------------------------
GNU grep:
$ time for i in `seq 1 100`; do /usr/gnu/bin/grep switch \
~/src/illumos/illumos-gate/usr/src/uts/common/io/* > /dev/null; done
real 0m37.744s
user 0m33.017s
sys 0m4.656s
BSD grep:
$ time for i in `seq 1 100`; do ~/ws/650-grep-q/usr/src/cmd/grep/grep \
switch ~/src/illumos/illumos-gate/usr/src/uts/common/io/* > /dev/null; \
done
real 0m19.577s
user 0m14.601s
sys 0m5.252s
----------------------------------------------------------------
----------------------------------------------------------------
Recursive:
----------------------------------------------------------------
GNU grep:
$ time for i in `seq 1 100`; do /usr/gnu/bin/grep -r switch \
~/src/illumos/illumos-gate/usr/src/uts/common/io/ > gnugrep.out; done
real 11m19.720s
user 9m46.833s
sys 1m31.770s
$ time for i in `seq 1 100`; do ~/ws/650-grep-q/usr/src/cmd/grep/grep -r \
switch ~/src/illumos/illumos-gate/usr/src/uts/common/io/ > bsdgrep.out; \
done
real 4m18.712s
user 3m9.223s
sys 1m8.911s
----------------------------------------------------------------
This looks much better...
Yuri
More information about the Developer
mailing list