summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--benchmarks.md53
-rwxr-xr-xtools/detailed_benchmarks.sh2
-rw-r--r--tools/format_benchmarks.awk35
3 files changed, 79 insertions, 11 deletions
diff --git a/benchmarks.md b/benchmarks.md
index fc06126..b5ea64a 100644
--- a/benchmarks.md
+++ b/benchmarks.md
@@ -34,14 +34,45 @@ interrupt runs.
## JavaScript libraries
-Here are some JavaScript benchmarks using `node.js`.
-They can be run using `make benchjs`. The source text is
-the CommonMark `README.md` file, but can be configured by
-setting the `BENCHINP` environment variable.
-
-Implementation | Ops/sec
-----------------|---------
-commonmark.js | 586
-showdown.js | 171
-marked.js | 564
-markdown-it | 760
+Here are some focused benchmarks of four JavaScript libraries.
+(using version available on 17 Jan 2015). They test performance
+on different kinds of Markdown texts. With the exception of
+the first (the `README.md` from this project), the samples are taken
+from the [markdown-it](https://github.com/markdown-it/markdown-it)
+repository. Results show a ratio of ops/second (higher is better)
+against the slowest implementation (always showdown).
+
+| Sample |showdown |commonmark|marked |markdown-it|
+|------------------------|---------:|---------:|---------:|----------:|
+|README.md | 1| 3.2| 3.1| 4.4|
+|block-bq-flat.md | 1| 8.0| 12.8| 11.3|
+|block-bq-nested.md | 1| 10.8| 9.9| 12.6|
+|block-code.md | 1| 24.9| 58.4| 83.2|
+|block-fences.md | 1| 16.4| 66.5| 65.5|
+|block-heading.md | 1| 10.7| 11.0| 17.5|
+|block-hr.md | 1| 14.4| 14.6| 37.7|
+|block-html.md | 1| 7.9| 2.8| 14.8|
+|block-lheading.md | 1| 14.4| 17.7| 26.1|
+|block-list-flat.md | 1| 4.3| 4.3| 10.4|
+|block-list-nested.md | 1| 7.4| 5.7| 19.1|
+|block-ref-flat.md | 1| 1.8| 1.1| 1.5|
+|block-ref-nested.md | 1| 1.5| 1.4| 2.4|
+|inline-autolink.md | 1| 4.1| 7.0| 4.5|
+|inline-backticks.md | 1| 15.8| 13.7| 30.7|
+|inline-em-flat.md | 1| 4.1| 3.8| 8.7|
+|inline-em-nested.md | 1| 5.2| 4.6| 8.3|
+|inline-em-worst.md | 1| 5.3| 4.9| 3.4|
+|inline-entity.md | 1| 4.8| 9.7| 7.7|
+|inline-escape.md | 1| 4.6| 2.9| 12.4|
+|inline-html.md | 1| 3.6| 5.2| 5.0|
+|inline-links-flat.md | 1| 3.7| 4.0| 4.1|
+|inline-links-nested.md | 1| 3.8| 1.0| 1.5|
+|inline-newlines.md | 1| 6.9| 6.5| 13.1|
+|rawtabs.md | 1| 8.9| 9.7| 13.4|
+
+To run these:
+
+1. `npm install marked showdown markdown-it`
+2. Create a `samples` subdirectory and copy the samples you
+ want to test into it.
+3. `sh tools/detailed_benchmarks.sh`
diff --git a/tools/detailed_benchmarks.sh b/tools/detailed_benchmarks.sh
new file mode 100755
index 0000000..8bc76b4
--- /dev/null
+++ b/tools/detailed_benchmarks.sh
@@ -0,0 +1,2 @@
+sudo echo ""
+for x in samples/*.md; do make benchjs BENCHINP=$x; done | awk -f tools/format_benchmarks.awk
diff --git a/tools/format_benchmarks.awk b/tools/format_benchmarks.awk
new file mode 100644
index 0000000..88dd7a3
--- /dev/null
+++ b/tools/format_benchmarks.awk
@@ -0,0 +1,35 @@
+#!/bin/sh env awk
+BEGIN {
+ CONVFMT="%2.1f";
+ print "| Sample |showdown |commonmark|marked |markdown-it|"
+ print "|------------------------|---------:|---------:|---------:|----------:|"
+}
+{
+ if (/samples\//) {
+ sub(/samples\//, "");
+ printf "|%-24s|", $7;
+ } else if (/^showdown/) {
+ sub(/,/, "");
+ showdown = $4;
+ } else if (/^commonmark/) {
+ sub(/,/, "");
+ commonmark = $4;
+ } else if (/^marked/) {
+ sub(/,/, "");
+ marked = $4;
+ } else if (/^markdown-it/) {
+ sub(/,/, "");
+ markdownit = $4;
+ printf "%10s|%10s|%10s|%11s|\n",
+ (showdown / showdown),
+ (commonmark / showdown),
+ (marked / showdown),
+ (markdownit / showdown);
+ markdownit = "";
+ showdown = "";
+ marked = "";
+ commonmark = "";
+ } else {
+ next;
+ }
+}