Optimizing league/commonmark

By Christophe Dujarric, on Jan 26, 2016

Colin O’Dell is the author and maintainer of the PHP League‘s CommonMark Markdown parser.

Besides striving to fully support the entire CommonMark spec, Colin also wants his parser’s implementation to be flexible enough so that users and contributors can add their own integrations, extensions and custom projects.

That increases the challenge in terms of performance management, and benchmarking his parser versus other popular ones show it lagging behind a little (even if not noticeably for users, as we’re talking 10s of milliseconds).

By using Blackfire, he quickly figured two simple changes could get him a total of 52,5% performance boost, bringing the parse time from 59ms down to 28ms!

Find out how he changed just a bit of logic in his code and still complied with the CommonMark spec. This article was written at the occasion of the #FireUpMyMac contest.

Christophe Dujarric

Christophe is the Chief Product Officer at Blackfire. He's an engineer, but probably one of the least "tech" people in the company. He's wearing many hats, from product management to marketing and sales. He loves the beauty of simple solutions that solve actual problems.