summaryrefslogtreecommitdiff
path: root/js/bench.js
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-07-21 22:29:16 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2014-08-13 22:56:32 -0700
commit870e63be7360b5a0097a27656048e853bc720464 (patch)
treee8f19ee2d62e529115cb71dcda5f3298cca7d389 /js/bench.js
parent650ad87f35f4405a2ca8270d2b2835daa442e5f1 (diff)
Initial commit
Diffstat (limited to 'js/bench.js')
-rw-r--r--js/bench.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/js/bench.js b/js/bench.js
new file mode 100644
index 0000000..3c486b1
--- /dev/null
+++ b/js/bench.js
@@ -0,0 +1,35 @@
+var Benchmark = require('benchmark').Benchmark;
+var suite = new Benchmark.Suite;
+var fs = require('fs');
+var sm = require('./stmd');
+// https://github.com/coreyti/showdown
+var showdown = require('../../showdown/src/showdown');
+// https://github.com/chjj/marked
+var marked = require('../../marked/marked.min.js');
+
+var benchfile = process.argv[2] || 'oldtests/Original/Markdown_Documentation_Syntax.markdown';
+
+var contents = fs.readFileSync(benchfile, 'utf8');
+
+// var converter = new showdown.converter();
+
+suite.add('stmd markdown->html', function() {
+ var doc = new sm.DocParser().parse(contents);
+ var renderer = new sm.HtmlRenderer();
+ renderer.renderBlock(doc);
+})
+
+.add('showdown.js markdown->html', function() {
+ var converter = new showdown.converter();
+ converter.makeHtml(contents);
+})
+
+.add('marked.js markdown->html', function() {
+ marked(contents);
+})
+
+.on('cycle', function(event) {
+ console.log(String(event.target));
+})
+.run();
+