Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions lib/matcha/reporters/markdown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*!
* Matcha - Markdown Reporter
* Created by J. Harshbarger, based on
* Matcha - Plain Reporter
* Copyright(c) 2013 Lauris Vavere <[email protected]>
* MIT Licensed
*/

/*!
* Internal Dependancies
*/
var platform = require('platform');


function pad(str, width) {
str = str.substr(0,width-3);
return str + ' ' + Array(width - str.length-2).join('.') + ' ';
};



/**
* Plain
*
* The markdown text matcha reporter.
*
* @param {Runner} runner
* @api public
*/

function desc(a,b) {
return b.stats.ops - a.stats.ops;
}

module.exports = function(runner, utils) {
var humanize = utils.humanize;

runner.on('start', function () {
console.log('# ' + platform.description);
});

runner.on('end', function (stats) {
console.log('');
/* console.log('Suites: ' + stats.suites);
console.log('Benches: ' + stats.benches);
console.log('Elapsed: ' + humanize(stats.elapsed.toFixed(2)) + ' ms'); */
});

runner.on('suite start', function (suite) {
console.log('');
console.log('## ' + suite.title);
console.log('');
});

runner.on('suite end', function (suite) {
if (suite.benches.length > 1) {
var benches = suite.benches.slice().sort(desc);
console.log('');
console.log('*Fastest is **' + benches[0].title + '***');
}
});

runner.on('bench start', function (bench) {
// process.stdout.write(' ' + pad(bench.title, 50));
});

runner.on('bench end', function (results) {
console.log(' ' + pad(results.title, 50) + humanize(results.ops.toFixed(0)) + ' op/s');
});
};
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
"author": "Jake Luer <[email protected]>",
"name": "matcha",
"description": "Benchmark your code.",
"keyword": [ "benchmark", "bench", "performance" ],
"keyword": [
"benchmark",
"bench",
"performance"
],
"version": "0.7.0",
"repository": {
"type": "git",
Expand All @@ -19,6 +23,7 @@
},
"dependencies": {
"electron": "0.4.x",
"platform": "^1.3.1",
"v8-argv": "0.1.x"
},
"devDependencies": {}
Expand Down