aboutsummaryrefslogtreecommitdiff
path: root/test/benchmark.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-04-14 03:13:42 +0100
committerGitHub <noreply@github.com>2020-04-14 10:13:42 +0800
commitc4d28e3b2a2d82c7e5e3b398513755b507a75e76 (patch)
tree955bed9c2cfb691ea84abf8476cc2dd0a507f907 /test/benchmark.js
parent77261e1ee037f3eea2d5ec80abb1387d4ba5c67e (diff)
downloadtracifyjs-c4d28e3b2a2d82c7e5e3b398513755b507a75e76.tar.gz
tracifyjs-c4d28e3b2a2d82c7e5e3b398513755b507a75e76.zip
expand testing on Node.js versions (#3779)
Diffstat (limited to 'test/benchmark.js')
-rw-r--r--test/benchmark.js15
1 files changed, 8 insertions, 7 deletions
diff --git a/test/benchmark.js b/test/benchmark.js
index 63009dd8..ea044b26 100644
--- a/test/benchmark.js
+++ b/test/benchmark.js
@@ -5,12 +5,11 @@
var createHash = require("crypto").createHash;
var fetch = require("./fetch");
-var fork = require("child_process").fork;
+var spawn = require("child_process").spawn;
var zlib = require("zlib");
var args = process.argv.slice(2);
-if (!args.length) {
- args.push("-mc");
-}
+args.unshift("bin/uglifyjs");
+if (!args.length) args.push("-mc");
args.push("--timings");
var urls = [
"https://code.jquery.com/jquery-3.4.1.js",
@@ -70,18 +69,20 @@ urls.forEach(function(url) {
};
fetch(url, function(err, res) {
if (err) throw err;
- var uglifyjs = fork("bin/uglifyjs", args, { silent: true });
+ var uglifyjs = spawn(process.argv[0], args, { silent: true });
res.on("data", function(data) {
results[url].input += data.length;
}).pipe(uglifyjs.stdin);
+ var sha1 = createHash("sha1");
uglifyjs.stdout.on("data", function(data) {
results[url].output += data.length;
}).pipe(zlib.createGzip({
level: zlib.Z_BEST_COMPRESSION
})).on("data", function(data) {
results[url].gzip += data.length;
- }).pipe(createHash("sha1")).on("data", function(data) {
- results[url].sha1 = data.toString("hex");
+ sha1.update(data);
+ }).on("end", function() {
+ results[url].sha1 = sha1.digest("hex");
done();
});
uglifyjs.stderr.setEncoding("utf8");