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

John Gruber gruber at fedora.net
Mon May 9 14:06:04 EDT 2005


Michel Fortin <michel.fortin at michelf.com> wrote on 05/09/05 at 10:48 am:

> 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)

That's great. But I've seen PHP Markdown get better times than
Markdown.pl in my testing script all along. My copy of Markdown.php
is 1.0.1 beta-something, and it beats the current version of
Markdown.pl.

It might be that the PHP version is faster, I really don't know. But
I don't think my testing harness is an accurate comparison, because
each test starts up an entirely new script interpretter. So each of
dozen-plus tests in the suite measures:

    time to start /usr/bin/perl or /usr/bin/php + time to run Markdown

and it might be that /usr/bin/php starts up faster than
/usr/bin/perl, but that Markdown.pl runs faster than Markdown.php
once each interpretter is up and running.

The main reason I thought the PHP version was slower than the Perl
version is that a few months ago, people were saying that it was
faster to call out to the shell and to run Markdown.pl from PHP than
it was to run PHP-Markdown. But I never tried timing that myself.


> 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.

Right. To me the main point is that both Markdown.php and
Markdown.pl are "fast enough" for most uses, but that doesn't mean
either is fast enough to run on each page view in a high-traffic
situation.

-J.G.


More information about the Markdown-Discuss mailing list