aboutsummaryrefslogtreecommitdiff
path: root/js/bench.js
blob: 3c486b11a2f8108185736e7d6da202a84ac80822 (plain)
  1. var Benchmark = require('benchmark').Benchmark;
  2. var suite = new Benchmark.Suite;
  3. var fs = require('fs');
  4. var sm = require('./stmd');
  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] || 'oldtests/Original/Markdown_Documentation_Syntax.markdown';
  10. var contents = fs.readFileSync(benchfile, 'utf8');
  11. // var converter = new showdown.converter();
  12. suite.add('stmd 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();