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 has been working in several start-up companies, helping them to make and sell products out of technologies. He’s involved in every step of the product’s lifecycle, from strategy to design and sales, and loves to coach on product management methods.