Skip to content

Commit

Permalink
perf(es/minifier): Change default pass limit to 2 (#4924)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Jun 10, 2022
1 parent 946f206 commit fc0d8e3
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 83 deletions.
2 changes: 1 addition & 1 deletion crates/swc/tests/fixture/issues-2xxx/2614/output/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
expose(function() {
return export_default;
});
var export_default = require("70jDX").default;
var Value, export_default = require("70jDX").default;
1 change: 1 addition & 0 deletions crates/swc/tests/fixture/sourcemap/004/output/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
888,
179
], function() {
var b;
return a(a.s = 7139);
}), _N_E = a.O();
},
Expand Down
3 changes: 2 additions & 1 deletion crates/swc/tests/fixture/sourcemap/004/output/index.map
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"mappings": "AEACA,CAAAA,IAAI,CAAC,gBAAkB,AAAC,GAAGA,IAAI,CAAC,gBAAkB,AAAC,IAAI,EAAE,CAAA,CAAEC,IAAI,CAAC;IAC7D;AAAC,WAAG;KAAC;IACL;AACU,QAAA,IAAI,EAAQ,SACdC,CAAuB,EACvBC,CAAmB,EACnBC,CAAmB,EACrB;YACE,YAAY,CAAC;gBFNxBC,CAAA,GAAA,SAAAC,CAAA,EAAA;gBAAA,IAAAC,CAAA,GAAAD,CAAA,CAAAC,IAAA;gBAAA,OAAA,CAAA,GCDDC,CAAA,CAAAC,GAAA,CAAA,CAAA,KAAA,EAAA;oBACAC,QAAA,EAAAH,CAAA,CAAAI,GAAA;iBACA,CAAA,CAAA;aACA;YAKYP,CAAmB,CAACQ,CAAC,CAACT,CAAmB,CAAC,EACrBC,CAAmB,CAACS,CAAC,CAACV,CAAmB,EAAE;gBACvCW,OAAO,EAAE,WAAY;oBACtC,OAAqBA,CAAO,CAAC;iBDZzB;gBAAqBC,OAAA,EAAA,WAAA;oBAC3C,OAAOV,CAAA,CAA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EAAE,WAAY;oBACtC,OAAqBA,CAAO,CAAC;iBDZzB;gBAAqBC,OAAA,EAAA,WAAA;oBAC3C,OAAOV,CAAA,CAAA;iBAAM;aACd,CAAA;YAAA,IAAAG,CAAA,GAAAJ,CAAA,CAAA,IAAA,CAAA,EAAAU,CAAA,GAAA,CAAA,CAAA;SCKM;AAKP,QAAA,IAAA,EAAA,SAAAZ,CAAA,EAAAc,CAAA,EAAAZ,CAAA,EAAA;YAAAa,CAAAA,MAAA,CAAAC,QAAA,GAAAD,MAAA,CAAAC,QAAA,IAAA,EAAA,CAAA,CAAAjB,IAAA,CAAA;gBAAA,SAAA;gBAAA,WAAA;oBAAA,OAAAG,CAAA,CAAA,IAAA,CAAA,CAAA;iBAAA;aAAA,CAAA,CAAA;SAAA;KAAA;IAAA,SAAAA,CAAA,EAAA;QAAAA,CAAA,CAAAe,CAAA,CAAA,CAAA,EAAA;AAAA,eAAA;AAAA,eAAA;AAAA,eAAA;SAAA,EAAA,WAAA;gBAAAC,CAAA;YAAA,OAAAhB,CAAA,CAAAA,CAAA,CAAAiB,CAAA,GAAA,IAAA,CAAA,CAAA;SAAA,CAAA,EAAAC,IAAA,GAAAlB,CAAA,CAAAe,CAAA,EAAA;KAAA;CAAA,CAAA,CAAA",
"names": [
"self",
"push",
Expand All @@ -21,6 +21,7 @@
"window",
"__NEXT_P",
"O",
"moduleId",
"s",
"_N_E"
],
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 29 additions & 29 deletions crates/swc/tests/vercel/full/ms/1/output/index.ts
Original file line number Diff line number Diff line change
@@ -1,72 +1,72 @@
var a = 86400000, b = 7 * a, c = 365.25 * a;
export default function(f, h) {
var b = 3600000, a = 24 * b, c = 7 * a, d = 365.25 * a;
export default function(g, i) {
try {
if ("string" == typeof f && f.length > 0) return function(e) {
if ((e = String(e)).length > 100) throw new Error("Value exceeds the maximum length of 100 characters.");
var f = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);
if (!f) return NaN;
var d = parseFloat(f[1]), g = (f[2] || "ms").toLowerCase();
switch(g){
if ("string" == typeof g && g.length > 0) return function i(f) {
if ((f = String(f)).length > 100) throw new Error("Value exceeds the maximum length of 100 characters.");
var g = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(f);
if (!g) return NaN;
var e = parseFloat(g[1]), h = (g[2] || "ms").toLowerCase();
switch(h){
case "years":
case "year":
case "yrs":
case "yr":
case "y":
return d * c;
return e * d;
case "weeks":
case "week":
case "w":
return d * b;
return e * c;
case "days":
case "day":
case "d":
return d * a;
return e * a;
case "hours":
case "hour":
case "hrs":
case "hr":
case "h":
return 3600000 * d;
return e * b;
case "minutes":
case "minute":
case "mins":
case "min":
case "m":
return 60000 * d;
return 60000 * e;
case "seconds":
case "second":
case "secs":
case "sec":
case "s":
return 1000 * d;
return 1000 * e;
case "milliseconds":
case "millisecond":
case "msecs":
case "msec":
case "ms":
return d;
return e;
default:
throw new Error("The unit ".concat(g, " was matched, but no matching case exists."));
throw new Error("The unit ".concat(h, " was matched, but no matching case exists."));
}
}(f);
if ("number" == typeof f && isFinite(f)) return (null == h ? void 0 : h.long) ? e(f) : d(f);
}(g);
if ("number" == typeof g && isFinite(g)) return (null == i ? void 0 : i.long) ? f(g) : e(g);
throw new Error("Value is not a string or number.");
} catch (i) {
var j = g(i) ? "".concat(i.message, ". value=").concat(JSON.stringify(f)) : "An unknown error has occurred.";
throw new Error(j);
} catch (j) {
var k = h(j) ? "".concat(j.message, ". value=").concat(JSON.stringify(g)) : "An unknown error has occurred.";
throw new Error(k);
}
};
function d(b) {
var c = Math.abs(b);
return c >= a ? "".concat(Math.round(b / a), "d") : c >= 3600000 ? "".concat(Math.round(b / 3600000), "h") : c >= 60000 ? "".concat(Math.round(b / 60000), "m") : c >= 1000 ? "".concat(Math.round(b / 1000), "s") : "".concat(b, "ms");
}
function e(c) {
var b = Math.abs(c);
return b >= a ? f(c, b, a, "day") : b >= 3600000 ? f(c, b, 3600000, "hour") : b >= 60000 ? f(c, b, 60000, "minute") : b >= 1000 ? f(c, b, 1000, "second") : "".concat(c, " ms");
var d = Math.abs(c);
return d >= a ? "".concat(Math.round(c / a), "d") : d >= b ? "".concat(Math.round(c / b), "h") : d >= 60000 ? "".concat(Math.round(c / 60000), "m") : d >= 1000 ? "".concat(Math.round(c / 1000), "s") : "".concat(c, "ms");
}
function f(d) {
var c = Math.abs(d);
return c >= a ? g(d, c, a, "day") : c >= b ? g(d, c, b, "hour") : c >= 60000 ? g(d, c, 60000, "minute") : c >= 1000 ? g(d, c, 1000, "second") : "".concat(d, " ms");
}
function f(b, c, a, d) {
function g(b, c, a, d) {
return "".concat(Math.round(b / a), " ").concat(d).concat(c >= 1.5 * a ? "s" : "");
}
function g(a) {
function h(a) {
return "object" == typeof a && null !== a && "message" in a;
}
3 changes: 2 additions & 1 deletion crates/swc/tests/vercel/full/next-31419/2/output/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ Promise.all(assignAll).then(function() {
var b = a(function*(c) {
for(let b in obj){
let a = obj[b];
a.id, (yield listOfUser(a.id)).forEach((b)=>{
a.id;
(yield listOfUser(a.id)).forEach((b)=>{
insertQuery += `INSERT INTO "TABLE"("UUID", id, other_ids_here) VALUES ('${uuidv4()}', '${a.id}', now());`;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ var ItemsList = function(_Component) {
}(ItemsList1, _Component);
var Derived, Constructor1, protoProps, staticProps, _super = (Derived = ItemsList1, function() {
var self, call, result, Super = _getPrototypeOf(Derived);
if (function() {
if (function _isNativeReflectConstruct() {
if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham) return !1;
if ("function" == typeof Proxy) return !0;
try {
Expand All @@ -108,7 +108,7 @@ var ItemsList = function(_Component) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else result = Super.apply(this, arguments);
return self = this, (call = result) && ("object" === _typeof(call) || "function" == typeof call) ? call : _assertThisInitialized(self);
return self = this, call = result, call && ("object" === _typeof(call) || "function" == typeof call) ? call : _assertThisInitialized(self);
});
function ItemsList1() {
var _this;
Expand Down

1 comment on commit fc0d8e3

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: fc0d8e3 Previous: 5bb417e Ratio
es/full/minify/libraries/antd 1180828171 ns/iter (± 7380144) 2555952428 ns/iter (± 11259122) 0.46
es/full/minify/libraries/d3 337843262 ns/iter (± 8921366) 629749257 ns/iter (± 12426696) 0.54
es/full/minify/libraries/echarts 1555499681 ns/iter (± 4350716) 2898365097 ns/iter (± 9299783) 0.54
es/full/minify/libraries/jquery 71443790 ns/iter (± 735410) 116629672 ns/iter (± 8654481) 0.61
es/full/minify/libraries/lodash 97959619 ns/iter (± 180052) 171076887 ns/iter (± 5028230) 0.57
es/full/minify/libraries/moment 41616680 ns/iter (± 98612) 65185182 ns/iter (± 829827) 0.64
es/full/minify/libraries/react 13657738 ns/iter (± 29050) 20627522 ns/iter (± 133650) 0.66
es/full/minify/libraries/terser 340588325 ns/iter (± 4818797) 605599482 ns/iter (± 10631162) 0.56
es/full/minify/libraries/three 381695459 ns/iter (± 3788339) 864793215 ns/iter (± 6209125) 0.44
es/full/minify/libraries/typescript 2922161640 ns/iter (± 21801238) 5820515322 ns/iter (± 34636969) 0.50
es/full/minify/libraries/victory 502115787 ns/iter (± 8034452) 1191687819 ns/iter (± 11883582) 0.42
es/full/minify/libraries/vue 108955424 ns/iter (± 905847) 188804105 ns/iter (± 8993503) 0.58
es/full/codegen/es3 25000 ns/iter (± 125) 34637 ns/iter (± 141) 0.72
es/full/codegen/es5 25005 ns/iter (± 290) 34593 ns/iter (± 160) 0.72
es/full/codegen/es2015 25011 ns/iter (± 144) 34591 ns/iter (± 126) 0.72
es/full/codegen/es2016 25027 ns/iter (± 120) 34603 ns/iter (± 193) 0.72
es/full/codegen/es2017 25025 ns/iter (± 2996) 34612 ns/iter (± 170) 0.72
es/full/codegen/es2018 25017 ns/iter (± 112) 34589 ns/iter (± 127) 0.72
es/full/codegen/es2019 25025 ns/iter (± 204) 34565 ns/iter (± 185) 0.72
es/full/codegen/es2020 25008 ns/iter (± 114) 34596 ns/iter (± 149) 0.72
es/full/all/es3 139616270 ns/iter (± 556042) 196065726 ns/iter (± 823056) 0.71
es/full/all/es5 131697075 ns/iter (± 496395) 186101109 ns/iter (± 1050325) 0.71
es/full/all/es2015 101679776 ns/iter (± 309780) 148328503 ns/iter (± 823789) 0.69
es/full/all/es2016 101021972 ns/iter (± 432020) 147216129 ns/iter (± 966197) 0.69
es/full/all/es2017 100413589 ns/iter (± 2970199) 146360313 ns/iter (± 893545) 0.69
es/full/all/es2018 98817693 ns/iter (± 569085) 144243937 ns/iter (± 714171) 0.69
es/full/all/es2019 98124776 ns/iter (± 541073) 144000126 ns/iter (± 849381) 0.68
es/full/all/es2020 93996532 ns/iter (± 717604) 139352743 ns/iter (± 743856) 0.67
es/full/parser 411160 ns/iter (± 32560) 597784 ns/iter (± 95659) 0.69
es/full/base/fixer 18342 ns/iter (± 254) 26925 ns/iter (± 256) 0.68
es/full/base/resolver_and_hygiene 100352 ns/iter (± 1482) 143394 ns/iter (± 1940) 0.70
serialization of ast node 131 ns/iter (± 0) 178 ns/iter (± 0) 0.74
serialization of serde 132 ns/iter (± 0) 180 ns/iter (± 0) 0.73

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.