more benchmarks
This commit is contained in:
parent
9ff55ae9d7
commit
628994fec1
@ -124,16 +124,6 @@ var bench = function() {
|
||||
var marked = require('../');
|
||||
main.bench('marked', marked);
|
||||
|
||||
/**
|
||||
* There's two ways to benchmark showdown here.
|
||||
* The first way is to create a new converter
|
||||
* every time, this will renew any closured
|
||||
* variables. It is the "proper" way of using
|
||||
* showdown. However, for this benchmark,
|
||||
* I will use the completely improper method
|
||||
* which is must faster, just to be fair.
|
||||
*/
|
||||
|
||||
var showdown = (function() {
|
||||
var Showdown = require('showdown').Showdown;
|
||||
var convert = new Showdown.converter();
|
||||
@ -141,7 +131,16 @@ var bench = function() {
|
||||
return convert.makeHtml(text);
|
||||
};
|
||||
})();
|
||||
main.bench('showdown', showdown);
|
||||
main.bench('showdown (reuse converter)', showdown);
|
||||
|
||||
var showdown_slow = (function() {
|
||||
var Showdown = require('showdown').Showdown;
|
||||
return function(text) {
|
||||
var convert = new Showdown.converter();
|
||||
return convert.makeHtml(text);
|
||||
};
|
||||
})();
|
||||
main.bench('showdown (new converter)', showdown_slow);
|
||||
|
||||
var markdownjs = require('markdown-js');
|
||||
main.bench('markdown-js', function(text) {
|
||||
@ -149,6 +148,11 @@ var bench = function() {
|
||||
});
|
||||
};
|
||||
|
||||
var time = function() {
|
||||
var marked = require('../');
|
||||
main.bench('marked', marked);
|
||||
};
|
||||
|
||||
var old_bench = function() {
|
||||
var text = fs.readFileSync(__dirname + '/main.md', 'utf8');
|
||||
|
||||
@ -311,6 +315,8 @@ var pretty = (function() {
|
||||
if (!module.parent) {
|
||||
if (~process.argv.indexOf('--bench')) {
|
||||
bench();
|
||||
} else if (~process.argv.indexOf('--time')) {
|
||||
time();
|
||||
} else if (~process.argv.indexOf('--old_bench')) {
|
||||
old_bench();
|
||||
} else if (~process.argv.indexOf('--old_test')) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user