bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/2] tests: add test for newly-fixed performance problem


From: Jim Meyering
Subject: Re: [PATCH 2/2] tests: add test for newly-fixed performance problem
Date: Tue, 04 May 2010 19:32:04 +0200

Paolo Bonzini wrote:
> * tests/backref-multibyte-slow: New.
> * tests/Makefile.am: Add it.
> ---
>  tests/Makefile.am            |    1 +
>  tests/backref-multibyte-slow |   28 ++++++++++++++++++++++++++++
>  2 files changed, 29 insertions(+), 0 deletions(-)
>  create mode 100644 tests/backref-multibyte-slow
>
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index fae2c85..fb8259d 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -30,6 +30,7 @@ TESTS =                                             \
>    backref.sh                                 \
>    backref-word                                       \
>    bre.sh                                     \
> +  backref-multibyte-slow                     \
>    case-fold-backref                          \
>    case-fold-backslash-w                              \
>    case-fold-char-class                               \
> diff --git a/tests/backref-multibyte-slow b/tests/backref-multibyte-slow
> new file mode 100644
> index 0000000..d0d2b53
> --- /dev/null
> +++ b/tests/backref-multibyte-slow
> @@ -0,0 +1,28 @@
> +#!/bin/sh
> +# This was approximately quadratic up to grep-2.6.3
> +: ${srcdir=.}
> +. "$srcdir/init.sh"; path_prepend_ ../src
> +
> +require_en_utf8_locale_
> +require_timeout_
> +
> +fail=0
> +
> +set -x
> +# Create a 12288-line input
> +echo aba | \
> +  sed 'p;p;p;p;p;p;p' | \
> +  sed 'p;p;p;p;p;p;p' | \
> +  sed 'p;p;p;p;p;p;p' | \
> +  sed 'p;p;p;p;p;p;p' | \
> +  sed 'p;p' > in

Nice.  Thanks a lot for adding a test.
How about using awk?  It's clearer and more efficient.
With it, you barely need the comment.

  $(AWK) 'BEGIN {for (i=0; i<13000; i++) print "aba"}' > in || fail=1

> +  wc -l in
> +for LOC in en_US.UTF-8; do
> +  out=out-$LOC
> +  LC_ALL=$LOC timeout 5s grep -E '^([a-z]).\1$' in > $out 2>&1

I confirmed that even on a very fast system, grep-2.6.3 does not
complete that test in under 5 seconds.

And even a very slow system usually completes it in less than 1 second.

> +  test $? = 0 || fail=1
> +  compare $out in || fail=1
> +done
> +
> +Exit $fail

ACK




reply via email to

[Prev in Thread] Current Thread [Next in Thread]