1. fix benchmark for showdown

2. remove discount benchmark // not working on v0.8.x
3. add robotskirt benchmark
4. add target of bench in Makefile
5. add devDependencies in package.json
This commit is contained in:
Hsiaoming Yang 2013-03-01 17:25:28 +08:00
parent 6959c202da
commit 6a30b517b1
5 changed files with 31 additions and 8 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
node_modules/

View File

@ -6,4 +6,7 @@ clean:
@rm marked.js @rm marked.js
@rm marked.min.js @rm marked.min.js
bench:
@node test --bench
.PHONY: clean all .PHONY: clean all

View File

@ -34,6 +34,19 @@ For those feeling skeptical: These benchmarks run the entire markdown test suite
1000 times. The test suite tests every feature. It doesn't cater to specific 1000 times. The test suite tests every feature. It doesn't cater to specific
aspects. aspects.
node v0.8.x
``` bash
$ node test --bench
marked completed in 3411ms.
marked (gfm) completed in 3727ms.
marked (pedantic) completed in 3201ms.
robotskirt completed in 808ms.
showdown (reuse converter) completed in 11954ms.
showdown (new converter) completed in 17774ms.
markdown-js completed in 17191ms.
```
## Install ## Install
``` bash ``` bash

View File

@ -12,5 +12,10 @@
"bugs": { "url": "http://github.com/chjj/marked/issues" }, "bugs": { "url": "http://github.com/chjj/marked/issues" },
"keywords": ["markdown", "markup", "html"], "keywords": ["markdown", "markup", "html"],
"tags": ["markdown", "markup", "html"], "tags": ["markdown", "markup", "html"],
"devDependencies": {
"markdown": "*",
"showdown": "*",
"robotskirt": "*"
},
"scripts": { "test": "node test", "bench": "node test --bench" } "scripts": { "test": "node test", "bench": "node test --bench" }
} }

View File

@ -237,13 +237,16 @@ function runBench(options) {
} }
bench('marked (pedantic)', marked); bench('marked (pedantic)', marked);
// Discount // robotskirt
var discount = require('discount').parse; var rs = require('robotskirt');
bench('discount', discount); bench('robotskirt', function(text) {
var parser = rs.Markdown.std();
return parser.render(text);
});
// Showdown (Reusing the converter) // Showdown (Reusing the converter)
var showdown = (function() { var showdown = (function() {
var Showdown = require('showdown').Showdown; var Showdown = require('showdown');
var convert = new Showdown.converter(); var convert = new Showdown.converter();
return function(text) { return function(text) {
return convert.makeHtml(text); return convert.makeHtml(text);
@ -253,7 +256,7 @@ function runBench(options) {
// Showdown // Showdown
var showdown_slow = (function() { var showdown_slow = (function() {
var Showdown = require('showdown').Showdown; var Showdown = require('showdown');
return function(text) { return function(text) {
var convert = new Showdown.converter(); var convert = new Showdown.converter();
return convert.makeHtml(text); return convert.makeHtml(text);
@ -263,9 +266,7 @@ function runBench(options) {
// markdown-js // markdown-js
var markdownjs = require('markdown'); var markdownjs = require('markdown');
bench('markdown-js', function(text) { bench('markdown-js', markdownjs.parse);
markdownjs.parse(text);
});
} }
/** /**