Repository navigation
Expand file tree
/
Copy pathrunner.js
More file actions
executable file
·68 lines (57 loc) · 1.88 KB
/
Copy pathrunner.js
File metadata and controls
executable file
·68 lines (57 loc) · 1.88 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env node
"use strict";
/* eslint-disable no-console */
const consoleReporter = require("./console-reporter");
const pathToSuites = require("./path-to-suites");
const benchmarks = require(".");
const fs = require("fs");
const path = require("path");
const toFileUrl = require("../lib/jsdom/utils").toFileUrl;
const optimist = require("optimist")
.usage("Run the jsdom benchmark suite")
.alias("s", "suites")
.string("s")
.describe("s", "suites that you want to run. ie: -s dom/construction/createElement,dom/foo")
.describe("bundle", "generate the JavaScript bundle required to run benchmarks in a browser")
.alias("h", "help")
.describe("h", "show the help");
if (optimist.argv.help) {
optimist.showHelp();
return;
}
if (optimist.argv.bundle) {
const bundle = require("browserify")({ debug: true });
bundle.require(path.resolve(__dirname, ".."), { expose: "jsdom" });
bundle.require(path.resolve(__dirname, "browser-runner.js"), { expose: "jsdom-browser-runner" });
bundle.bundle()
.pipe(fs.createWriteStream(path.resolve(__dirname, "browser-bundle.js")))
.on("finish", () => {
console.info("Open the following page in Chrome to begin benchmarking:",
toFileUrl(path.resolve(__dirname, "browser-runner.html")));
});
return;
}
let suitesToRun;
if (optimist.argv.suites) {
suitesToRun = pathToSuites(benchmarks, optimist.argv.suites.trim().split(/,/));
} else {
suitesToRun = pathToSuites(benchmarks);
}
suitesToRun.forEach(consoleReporter);
function runNext() {
/* eslint-disable no-invalid-this */
if (this && this.off) {
// there is no .once()
this.off("complete", runNext);
}
/* eslint-enable no-invalid-this */
const suite = suitesToRun.shift();
if (!suite) {
console.log("Done!");
return;
}
suite.off("complete", runNext);
suite.on("complete", runNext);
suite.run({ async: true });
}
runNext();