summaryrefslogtreecommitdiff
path: root/js/bench.js
blob: ea68161f33d80cac52b0d074fdb4fa80f13842cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var Benchmark = require('benchmark').Benchmark;
var suite = new Benchmark.Suite;
var fs = require('fs');
var sm = require('./lib/index.js');
// 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];

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();