Benchmarks with TextMate's manual

John Fraser john at attacklab.net
Tue Aug 28 16:51:15 EDT 2007


On 8/28/07, Michel Fortin <michel.fortin at michelf.com> wrote:

> I'm not quite sure what's the culprit in Markdown.pl, although I

> suspect the overuse of the HTML block parser to hash Markdown-

> generated markup is part of it. That's one thing I've removed in the

> many architectural changes PHP Markdown passed through since version

> 1.0.1d.


I found a couple of problems with Markdown.pl when I ported it to
JavaScript, but I don't know whether they're enough to explain the
non-linear slowdown we're seeing. Off the top of my head, there's the
MD5 stuff (which was obviously meant to be temporary) and an exploding
regexp in _Detab (which can be fixed with \G). My guess is that once
those are fixed, the other problems will become obvious with a little
testing.


> Sure. 49 seconds (for the 176 Kb document). Oh, and parsing the

> double-sized document (352 Kb) took 289 seconds (almost 5 minutes!).

> That's clearly not linear.


So even if we optimized the rest of Markdown.pl so that it handled the
TextMate manual in 1.5 seconds, we'd still be stuck at around 33.5
seconds -- 95% of which is the new HTML block parser. Looks like any
optimization of Markdown.pl would have to start with a look at the
Text::Balanced stuff.

John Fraser


More information about the Markdown-Discuss mailing list