forked from quantizor/markdown-to-jsx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbenchmark.js
26 lines (23 loc) · 980 Bytes
/
benchmark.js
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
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 });