Re: Speed comparison of regex versus index, lc, and / /i
- From: nolo contendere <simon.chao@xxxxxxx>
- Date: Fri, 30 May 2008 07:20:40 -0700 (PDT)
On May 30, 10:10 am, Ben Bullock <benkasminbull...@xxxxxxxxx> wrote:
On Fri, 30 May 2008 13:28:21 +0000, John W. Krahn wrote:
Just the opposite. AFAIK if searching for a literal string (as opposed
to a regular expression pattern) the regexp engine will use the same
algorithm as index().
I don't know what it does internally, but actually using non-literal
strings in the regular expression match like "something|else" or
"first.*second" did not result in a significant slowdown. The search
string did not change at all during the execution of the program, so
the regular expression would only have been compiled once.
I assume that most of the slowdown was caused by the introduction of the
use of UTF, etc.
No - the "lc"-related slowdown was experienced even if I read in the
files as bytes and did not convert them into anything. I'm sure of
this because I converted to using UTF-8 halfway through coding because
of an unrelated problem, and by that point I'd already noticed that "lc"
or / /i more than doubled the time of the program execution. In fact at the
same time that I converted the searched files into UTF-8, I also converted
them to lower case.
Could you post the code you used to compare, as well as the output?
I'm assuming you used Benchmark, please correct me if I'm wrong.
Also, what's the output of perl -V, and what are your system specs?
.
- References:
- Speed comparison of regex versus index, lc, and / /i
- From: Ben Bullock
- Re: Speed comparison of regex versus index, lc, and / /i
- From: John W. Krahn
- Re: Speed comparison of regex versus index, lc, and / /i
- From: Ben Bullock
- Speed comparison of regex versus index, lc, and / /i
- Prev by Date: Re: Using perl locally on a Windows XP system
- Next by Date: Re: Speed comparison of regex versus index, lc, and / /i
- Previous by thread: Re: Speed comparison of regex versus index, lc, and / /i
- Next by thread: Re: Speed comparison of regex versus index, lc, and / /i
- Index(es):
Relevant Pages
|