Colin O’Dell, author and maintainer of the PHP League’s CommonMark Markdown parser, obtained a 52.5% performance boost by making two simple changes.
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.