# Tests and Benchmark

## Tests

There exist several test suites for testing the correctness of a Markdown implementation. The original Markdown Test Suite is the standard which one needs to test against. The PHP Markdown suite contains the original test suite and several more tests (some specifically geared towards the extension of the PHP Markdown Extra package). I have used the latter test tool to roughly verify that kramdown is able to parse standard Markdown. However, since the syntax used by kramdown varies slightly from standard Markdown most of the tests fail - which is fine. When looking at the differences one can see that the failures result from these differences.

Besides using the above mentioned test suite kramdown comes with its own set of tests which is used to verify that the implementation matches the kramdown specification.

If you believe you have found a bug in the implementation, please follow these steps:

• Check the syntax page and see if the behaviour is not intended.

• If the behaviour is not intended and it seems that kramdown should parse some text in another fashion, please open a bug report and attach two files: one with the text and one with the HTML conversion you think is correct.

## Benchmark

kramdown comes with a small benchmark to test how fast it is in regard to four other Ruby Markdown implementations: Maruku, BlueFeather, BlueCloth, RDiscount and Redcarpet. The first two are written using only Ruby, the latter three are written in C and need to be compiled.

As one can see below, kramdown is currently (September 2014) ~3x faster than Maruku, ~4.5x faster than BlueFeather but ~30x slower than RDiscount and ~150x slower than Redcarpet:


Running tests on 2014-09-16 under ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]

Test using file mdsyntax.text and 20 runs
Rehearsal ----------------------------------------------------
kramdown 1.4.2     0.900000   0.010000   0.910000 (  0.914992)
Maruku 0.7.1       2.360000   0.040000   2.400000 (  2.403571)
BlueFeather 0.41   3.760000   0.010000   3.770000 (  3.776421)
BlueCloth 2.2.0    0.050000   0.000000   0.050000 (  0.050221)
RDiscount 2.1.7    0.020000   0.000000   0.020000 (  0.024180)
redcarpet 3.1.2    0.010000   0.000000   0.010000 (  0.004579)
------------------------------------------- total: 7.160000sec

user     system      total        real
kramdown 1.4.2     0.830000   0.000000   0.830000 (  0.834144)
Maruku 0.7.1       2.250000   0.030000   2.280000 (  2.286579)
BlueFeather 0.41   3.680000   0.010000   3.690000 (  3.693769)
BlueCloth 2.2.0    0.050000   0.000000   0.050000 (  0.044831)
RDiscount 2.1.7    0.020000   0.000000   0.020000 (  0.022847)
redcarpet 3.1.2    0.010000   0.000000   0.010000 (  0.004601)

Real time of X divided by real time of kramdown
Maruku             2.7412
BlueFeather        4.4282
BlueCloth          0.0537
RDiscount          0.0274
redcarpet          0.0055

Test using file mdbasics.text and 20 runs
Rehearsal ----------------------------------------------------
kramdown 1.4.2     0.150000   0.000000   0.150000 (  0.149989)
Maruku 0.7.1       0.580000   0.010000   0.590000 (  0.584910)
BlueFeather 0.41   0.780000   0.000000   0.780000 (  0.788740)
BlueCloth 2.2.0    0.020000   0.000000   0.020000 (  0.014700)
RDiscount 2.1.7    0.000000   0.000000   0.000000 (  0.007692)
redcarpet 3.1.2    0.010000   0.000000   0.010000 (  0.002064)
------------------------------------------- total: 1.550000sec

user     system      total        real
kramdown 1.4.2     0.150000   0.000000   0.150000 (  0.151586)
Maruku 0.7.1       0.520000   0.000000   0.520000 (  0.525707)
BlueFeather 0.41   0.770000   0.010000   0.780000 (  0.763559)
BlueCloth 2.2.0    0.020000   0.000000   0.020000 (  0.015509)
RDiscount 2.1.7    0.010000   0.000000   0.010000 (  0.006545)
redcarpet 3.1.2    0.000000   0.000000   0.000000 (  0.001475)

Real time of X divided by real time of kramdown
Maruku             3.468
BlueFeather        5.0371
BlueCloth          0.1023
RDiscount          0.0432
redcarpet          0.0097


And here are some graphs which show the execution times of the various kramdown releases on different Ruby interpreters: