PHP Markdown, speed, MovableType (was "Michel Fortin")

John Gruber gruber at fedora.net
Tue Dec 7 13:58:16 EST 2004


Michael Tsai <lists at mjtsai.com> wrote on 12/07/04 at 1:48pm:

> Looking at the PHP source (both 4.3.8 and 5.0.2) it seems that it does 
> cache compiled patterns.

Thanks a bunch for investigating this. (*Checks item off to-do list...*)


> and ran Sampler on it. (You have to compile PHP yourself to do this; 
> otherwise Sampler won't have access to debugging symbols.) The result 
> is that 50x more time is spent in PCRE's "match" function than anywhere 
> else, and almost no time is spent in "pcre_get_compiled_regex." PCRE 
> just isn't as fast as Perl, although perhaps it's possible to tune the 
> patterns to make them match faster.

Interesting. Well, at least it backs up my larger hunch, that the
problem is that the "lots of regex substitutions" strategy probably
isn't a good one for PHP.


> > Python, on the other hand, allows the programmer to optionally
> > control the compilation of patterns before using them:
> 
> Also, it automatically caches a fixed number of compiled regexes, even 
> if you don't use re.compile.

Yeah, I thought so. (I wish Friedl had covered Python more
extensively in the 2nd ed. of "Mastering Regular Expressions"...)

-J.G.


More information about the Markdown-discuss mailing list