[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [grep] about 200 times slower than Sed or Perl
From: |
Paolo Bonzini |
Subject: |
Re: [grep] about 200 times slower than Sed or Perl |
Date: |
Fri, 12 Mar 2004 22:25:08 +0100 |
> The problem is indeed related to the locale. With non-UTF-8 locale, I
> get the usual speed. With an UTF-8 locale and "-v MAC" I get the
> breakdown described in the original report. But grep -v MÄC (for
> example, an UTF-8 string) is fast, OTOH. Very confusing results.
Confusing but easy to explain. grep treats MÄC as a multibyte string, perl
ignores the locale completely, and sed (via glibc) has a special optimization
that is specific to the UTF-8 locale that allows it to run at its full speed
(which is slower than grep). If you put in the ring super-sed as well
(http://sed.sf.net/grabbag) you'll find that it ignores the locale completely
as well, and is a bit faster than perl.
Paolo