Re: Speed comparison of regex versus index, lc, and / /i
- From: "A. Sinan Unur" <1usa@xxxxxxxxxxxxxxxxxxx>
- Date: Sat, 31 May 2008 14:44:04 GMT
Ben Bullock <benkasminbullock@xxxxxxxxx> wrote in
news:g1qn82$3i2$1@xxxxxxxxxxxxxxxx:
On Sat, 31 May 2008 01:49:14 +0000, A. Sinan Unur wrote:
There is one change I would make to both routines. Cache length $ss
before the loop. On my machine, that cut down the time by about 40%.
In the real situation almost every search for the search string ($ss)
in the text ($text) is going to fail, so I think it would make much
less difference than in the fake situation of repeating with the same
string over and over again.
True.
I modified the program to use /o that A. Sinan Unur added, and also
added a routine to test Ben Morrow's idea and reran it using the
Benchmark module:
Thank you for collecting all these ideas and running and reporting the
test results.
Let me clarify one point: I wasn't advocating the use of /o. I wanted to
point out that the 4% speed advantage of index which I had observed
disappeared with the use of /o. Of course, correct usage is more
important than speed and as Abigail noted, the use of /o could create
nasty behavior in this case.
I am not going to change my practice of searching for or checking the
existence of literal strings in text using index because that makes
intuitive sense to me.
Sinan
--
A. Sinan Unur <1usa@xxxxxxxxxxxxxxxxxxx>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/
.
- Follow-Ups:
- Re: Speed comparison of regex versus index, lc, and / /i
- From: Jürgen Exner
- Re: Speed comparison of regex versus index, lc, and / /i
- References:
- Speed comparison of regex versus index, lc, and / /i
- From: Ben Bullock
- Re: Speed comparison of regex versus index, lc, and / /i
- From: xhoster
- Re: Speed comparison of regex versus index, lc, and / /i
- From: Ben Bullock
- Re: Speed comparison of regex versus index, lc, and / /i
- From: A. Sinan Unur
- 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: Speed comparison of regex versus index, lc, and / /i
- 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):