Home > markdown-perf

markdown-perf

Markdown-perf is a project mainly written in ColdFusion, it's free.

Performance tests of MarkdownSharp vs. jMD, as called by ColdFusion

What The ... ?

This code is published as a sanity check for performance testing I've been running.

What's being tested? Why?

I am a somewhat recent convert to the Markdown religion. When Stack Overflow went into beta, I started using it heavily and fell madly in love. Thus, when I see an opportunity to use it in my own work, I pounce on it.

I'm working on a ColdFusion application that could benefit from Markdown. As such, I wanted to use a Markdown library - why reinvent the wheel? I've looked at MarkdownJ in the past, but remember some complaints about bugs when the MD syntax gets sufficiently complex. That said, MarkdownJ has an existing ColdFusion implementation, which makes it slightly more attractive. However, ColdFusion 8+ has the ability to access .NET assemblies and I just so happen to know of a Markdown implementation in C#, called MarkdownSharp ("MD#"). I know that the primary goals of the MD# project are to fix as many of those formatting bugs as possible, and to be fast. And honestly, if it's good enough for those anal-retentive nerds using Stack Overflow every day, it's good enough for me.

I put together a reference implementation to start playing with MD#, but was quickly alerted by some friends that there is a native Java port of MD#, called jMD. The theory was that since ColdFusion runs on the JVM, and jMD is native Java, it would run faster than a .Net assembly being accessed over a Java->.Net bridge.

So far, my testing has proven otherwise (iteration test, complex document test). I'm not sure if it's a nuance of implementation, or if .Net is just better at text parsing with Regex, or something else... but the fact remains that so far my tests show that MD#, even running over the Java->.Net bridge, runs roughly twice as fast as jMD.

I had originally used JavaLoader to create an instance of jMD to test with because it was easy, but there was some concern over whether that added additional overhead to the transform operation. I rewrote my test script to include a 3rd test: jMD loaded from the JVM's ClassPath. Not only did MD# continue to beat jMD by a not-insignificant amount, but I've also confirmed that once the class is instantiated (via JavaLoader or via ClassPath), the speed of the transform operation is virtually indistinguishable.

That's where you come in.

I'm posting this code online as a sanity check. If you see a flaw in the tests, please point it out (or fix it!). In the end, my goal is to use the fastest library with the best formatting for my project. I have no agenda: I don't care if it's .Net or Java.

Previous:ideacollector