[Python-Dev] SRE 0.9.8 benchmarks (original) (raw)

M.-A. Lemburg mal@lemburg.com
Thu, 03 Aug 2000 11:17:46 +0200


searching for literal text: searching for "spam" in a string padded with "spaz" (1000 bytes on each side of the target): string.find 0.112 ms sre8.search 0.059 pre.search 0.122 unicode.find 0.130 sre16.search 0.065 (yes, regular expressions can run faster than optimized C code -- as long as we don't take compilation time into account ;-) same test, without any false matches: string.find 0.035 ms sre8.search 0.050 pre.search 0.116 unicode.find 0.031 sre16.search 0.055

Those results are probably due to the fact that string.find does a brute force search. If it would do a last match char first search or even Boyer-Moore (this only pays off for long search targets) then it should be a lot faster than [s|p]re.

Just for compares: would you mind running the search routines in mxTextTools on the same machine ?

import TextTools TextTools.find(text, what)

-- Marc-Andre Lemburg


Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/