aboutsummaryrefslogtreecommitdiff
path: root/js/bench.js
blob: f23eb1a7f736bde4b90c67ca04650046ef2937fa (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. suite.add('commonmark.js markdown->html', function() {
  12. "use strict";
  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. "use strict";
  19. var converter = new showdown.converter();
  20. converter.makeHtml(contents);
  21. })
  22. .add('marked.js markdown->html', function() {
  23. "use strict";
  24. marked(contents);
  25. })
  26. .on('cycle', function(event) {
  27. "use strict";
  28. console.log(String(event.target));
  29. })
  30. .run();