aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-07-09 01:44:59 +0800
committerGitHub <noreply@github.com>2017-07-09 01:44:59 +0800
commit4956ad311b363374211b7767b58b80098bac1ee3 (patch)
tree011bc45eb80345cef58ff6397221107494174664
parent145874e50401137e573f180e1b36ccb5b547840b (diff)
downloadtracifyjs-4956ad311b363374211b7767b58b80098bac1ee3.tar.gz
tracifyjs-4956ad311b363374211b7767b58b80098bac1ee3.zip
benchmark gzipped output (#2220)
-rw-r--r--test/benchmark.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/benchmark.js b/test/benchmark.js
index e34f0858..569d4476 100644
--- a/test/benchmark.js
+++ b/test/benchmark.js
@@ -6,6 +6,7 @@
var createHash = require("crypto").createHash;
var fetch = require("./fetch");
var fork = require("child_process").fork;
+var zlib = require("zlib");
var args = process.argv.slice(2);
if (!args.length) {
args.push("-mc");
@@ -33,6 +34,7 @@ function done() {
console.log(info.log);
console.log("Original:", info.input, "bytes");
console.log("Uglified:", info.output, "bytes");
+ console.log("GZipped: ", info.gzip, "bytes");
console.log("SHA1 sum:", info.sha1);
if (info.code) {
failures.push(url);
@@ -51,6 +53,7 @@ urls.forEach(function(url) {
results[url] = {
input: 0,
output: 0,
+ gzip: 0,
log: ""
};
fetch(url, function(err, res) {
@@ -65,6 +68,11 @@ urls.forEach(function(url) {
results[url].sha1 = data.toString("hex");
done();
});
+ uglifyjs.stdout.pipe(zlib.createGzip({
+ level: zlib.Z_BEST_COMPRESSION
+ })).on("data", function(data) {
+ results[url].gzip += data.length;
+ });
uglifyjs.stderr.setEncoding("utf8");
uglifyjs.stderr.on("data", function(data) {
results[url].log += data;