Added separate command for reference benchmark.

pull/90/head
Nicolas Perriault 9 years ago committed by Gijs Kruitbosch
parent 1e14d47bb7
commit 2bfa678cab

@ -1,12 +1,36 @@
var getTestPages = require("./test/bootstrap").getTestPages;
var readability = require("./index.js");
var Readability = readability.Readability;
var JSDOMParser = readability.JSDOMParser;
suite("Readability test suite benchmarks", function () {
set("iterations", 100);
var referenceTestPages = [
"002",
"herald-sun-1",
"lifehacker-working",
"lifehacker-post-comment-load",
"medium-1",
"medium-2",
"salon-1",
"tmz-1",
"wapo-1",
"wapo-2",
"webmd-1",
];
var testPages = getTestPages();
if (process.env.READABILITY_PERF_REFERENCE === "1") {
testPages = testPages.filter(function(testPage) {
return referenceTestPages.indexOf(testPage.dir) !== -1;
});
}
suite("Readability test page perf", function () {
set("iterations", 1);
set("type", "static");
require("./test/bootstrap").getTestPages().forEach(function(testPage) {
testPages.forEach(function(testPage) {
bench(testPage.dir + " perf", function() {
new JSDOMParser().parse(testPage.source);
});

@ -1,9 +1,5 @@
var path = require("path");
var fs = require("fs");
var prettyPrint = require("html").prettyPrint;
var chai = require("chai");
chai.config.includeStack = true;
var expect = chai.expect;
// We want to load Readability and JSDOMParser, which aren't set up as commonjs libraries,
// and so we need to do some hocus-pocus with 'vm' to import them on a separate scope

@ -6,7 +6,8 @@
"scripts": {
"test": "mocha test/test-*.js",
"generate-testcase": "node test/generate-testcase.js",
"perf": "matcha benchmarks.js"
"perf": "matcha benchmarks.js",
"perf-reference": "READABILITY_PERF_REFERENCE=1 matcha benchmarks.js"
},
"repository": {
"type": "git",

1
test/bootstrap.js vendored

@ -1,5 +1,6 @@
var path = require("path");
var fs = require("fs");
var prettyPrint = require("html").prettyPrint;
function readFile(path) {
return fs.readFileSync(path, {encoding: "utf-8"}).trim();

Loading…
Cancel
Save