PHP Markdown, speed
Michel Fortin
michel.fortin at michelf.com
Tue Dec 7 19:19:00 EST 2004
Le 7 déc. 2004, à 13:48, Michael Tsai a écrit :
> Looking at the PHP source (both 4.3.8 and 5.0.2) it seems that it does
> cache compiled patterns.
I guess it maintains some kind of an hash table with every regex it
already compiled... is that true?
> [...] PCRE just isn't as fast as Perl, although perhaps it's possible
> to tune the patterns to make them match faster.
Maybe the /S modifier could be applied to some regex to improve speed.
I'm just not sure which ones. Quoted from [this page][1] about PCRE
modifiers:
> *S Modifier*
> When a pattern is going to be used several times, it is worth
> spending more time analyzing it in order to speed up the time taken
> for matching. If this modifier is set, then this extra analysis is
> performed. At present, studying a pattern is useful only for
> non-anchored patterns that do not have a single fixed starting
> character.
[1]: http://www.zend.com/manual/reference.pcre.pattern.modifiers.php
European Bob wrote:
> PS. would it be possible to time the PHP version tightly? maybe there
> is
> one specific area which is *really* bad - going through with some
> microtimes() and seeing which large chunks are sucking all the time
> might finger one obvious culprit. If it's just generally bad... well,
> lose ;)
This is exactly what I did when debugging 1.0.1b2. I made a special
version of PHP Markdown that output everywhere in the program the
elapsed time since the start of the call to Markdown. There was one bad
function -- _DoHeader -- and I fixed it in 1.0.1b2.
Since there is some interest in this, I've put it on the dingus
temporarily. In the filter menu, choose "MD Internal Timer" and try
what you want. (It does not include any bug corrections made after
1.0.1b2).
If someone wants the php file, just ask (off list).
Michel Fortin
michel.fortin at michelf.com
http://www.michelf.com/
More information about the Markdown-discuss
mailing list