Skip to content

Commit

Permalink
add benchmark for my own use
Browse files Browse the repository at this point in the history
  • Loading branch information
quantizor committed Nov 19, 2018
1 parent 1bc4d23 commit d085f94
Show file tree
Hide file tree
Showing 3 changed files with 684 additions and 18 deletions.
26 changes: 26 additions & 0 deletions benchmark.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import BenchTable from 'benchtable';
import * as fs from 'fs';
import ReactMarkdown from 'react-markdown';
import SimpleMarkdown from 'simple-markdown';
import MarkdownIt from 'markdown-it';
import { compiler } from './';

const mdIt = new MarkdownIt();
const suite = new BenchTable();

const fixture = fs.readFileSync('./fixture.md', 'utf8');

// add tests
suite
.addFunction('markdown-to-jsx', input => compiler(input))
.addFunction('react-markdown', input => new ReactMarkdown({ source: input }))
.addFunction('simple-markdown', input => SimpleMarkdown.defaultReactOutput(SimpleMarkdown.defaultBlockParse(input)))
.addFunction('markdown-it', input => mdIt.render(input))
.addInput('simple markdown string', ['_Hello_ **world**!'])
.addInput('large markdown string', [fixture])
.on('complete', function() {
console.log('Fastest is ' + suite.filter('fastest').map('name'));
console.log(suite.table.toString());
})
// run async
.run({ 'async': true });
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,18 @@
"babel-preset-minify": "^0.5.0",
"babel-preset-react": "^6.11.1",
"babel-preset-stage-2": "^6.13.0",
"benchtable": "^0.1.0",
"codecov": "^3.1.0",
"emotion": "^9.2.12",
"eslint": "^5.7.0",
"eslint-config-prettier": "^3.1.0",
"eslint-plugin-react": "^7.11.1",
"esm": "^3.0.84",
"in-publish": "^2.0.0",
"jest": "^23.6.0",
"jest-serializer-html": "^5.0.0",
"markdown-it": "^8.4.2",
"microtime": "^2.1.8",
"mkdirp": "^0.5.1",
"polished": "^1.3.0",
"preact": "^8.3.1",
Expand All @@ -55,7 +59,9 @@
"prettier": "^1.14.3",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react-markdown": "^4.0.3",
"rimraf": "^2.6.2",
"simple-markdown": "^0.4.2",
"size-limit": "^0.20.1",
"uglify-js": "^3.4.9",
"webpack": "^4.21.0",
Expand All @@ -78,7 +84,8 @@
"release:debug": "webpack --config ./webpack.config.babel.js --display-optimization-bailout",
"start": "webpack-dev-server --hot --inline --open",
"test": "jest --verbose",
"size": "size-limit"
"size": "size-limit",
"benchmark": "node -r esm benchmark.js"
},
"size-limit": [
{
Expand Down
Loading

0 comments on commit d085f94

Please sign in to comment.