Performance (Was: Problems with incorporating markdown into a project)

Michel Fortin michel.fortin at michelf.com
Mon May 9 10:48:30 EDT 2005


Le 9 mai 2005, à 0:18, John Gruber a écrit :

> I could be wrong, but I don't think PHP Markdown could do
> 5,000-10,000 hits per hours, and if you're using the Perl version,
> you almost certainly couldn't get away with firing up that many
> instances of Markdown via CGI.

I got a surprise some days ago while benchmarking PHP Markdown. 
According to MarkdownTest, PHP Markdown 1.0.2b2 is about 2 times faster 
than the same version in Perl. I can't believe it.

Here are the result (after a few runs so that everything is cached):

Perl Markdown 1.0.2b2:
4 wallclock secs ( 0.04 usr  0.07 sys +  2.72 cusr  0.73 csys =  3.56 
CPU)

PHP Markdown 1.0.2b2:
2 wallclock secs ( 0.05 usr  0.04 sys +  1.30 cusr  0.61 csys =  2.00 
CPU)

(iBook G4 1.2 GHz, with automatic processor speed adjustment)
(Perl v5.8.1-RC3)
(PHP 4.3.10)

One think I noted is that PHP Markdown 1.0, despite having a big 
performance problem with long lines of text, runs just a little slower 
than version 1.0.2b2 according to MarkdownTest (but still faster than 
Perl!). While this is true for the tests MarkdownTest runs, if I throw 
at PHP Markdown 1.0 a document which isn't hard-wrapped and has very 
big paragraphs in it, it takes forever. So which one is faster? Hum...

* * *

I've just finished running a small script running PHP Markdown 1.0.2b2 
1000 times over my French translation of the Markdown syntax document. 
It took 514 seconds (8 minutes 34 seconds) on my iBook. If I multiply 
by 10 to approximate the time it would take to convert it 10,000 times, 
I get 5140 seconds (1 hour 25 minutes 40 seconds).

So no it couldn't handle 10,000 hits per hours by converting this 
document on the fly, but this is with a pretty big document. But 
according to this it probably could for smaller ones (assuming your CMS 
is much optimized and your server is really fast).

But I still think the result must be cached if you want a good 
performance.


Michel Fortin
michel.fortin at michelf.com
http://www.michelf.com/


More information about the Markdown-Discuss mailing list