aboutsummaryrefslogtreecommitdiff
path: root/js/bench.js
blob: d068a7eec081900513fcbb6d5133db787f70ff4b (plain)
  1. var Benchmark = require('benchmark').Benchmark;
  2. var suite = new Benchmark.Suite;
  3. var fs = require('fs');
  4. var sm = require('./lib/index.js');
  5. // https://github.com/coreyti/showdown
  6. var showdown = require('../../showdown/src/showdown');
  7. // https://github.com/chjj/marked
  8. var marked = require('../../marked/marked.min.js');
  9. var benchfile = process.argv[2];
  10. var contents = fs.readFileSync(benchfile, 'utf8');
  11. // var converter = new showdown.converter();
  12. suite.add('commonmark.js markdown->html', function() {
  13. var doc = new sm.DocParser().parse(contents);
  14. var renderer = new sm.HtmlRenderer();
  15. renderer.renderBlock(doc);
  16. })
  17. .add('showdown.js markdown->html', function() {
  18. var converter = new showdown.converter();
  19. converter.makeHtml(contents);
  20. })
  21. .add('marked.js markdown->html', function() {
  22. marked(contents);
  23. })
  24. .on('cycle', function(event) {
  25. console.log(String(event.target));
  26. })
  27. .run();