Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(es/minifier): Consider function body cost while inlining function (…
- Loading branch information
Showing
66 changed files
with
1,234 additions
and
1,520 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,5 @@ | ||
//// [ES5For-of10.ts] | ||
function foo() { | ||
return { | ||
x: 0 | ||
}; | ||
} | ||
for(var _i = 0, _iter = []; _i < _iter.length; _i++){ | ||
foo().x = _iter[_i]; | ||
for(var _i1 = 0, _iter1 = []; _i1 < _iter1.length; _i1++)foo().x = _iter1[_i1], foo().x; | ||
_iter[_i]; | ||
for(var _i1 = 0, _iter1 = []; _i1 < _iter1.length; _i1++)_iter1[_i1]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,6 @@ | ||
//// [ES5For-of34.ts] | ||
function foo() { | ||
return { | ||
x: 0 | ||
}; | ||
} | ||
for(var _i = 0, _iter = [ | ||
"a", | ||
"b", | ||
"c" | ||
]; _i < _iter.length; _i++)foo().x = _iter[_i], foo().x; | ||
]; _i < _iter.length; _i++)_iter[_i]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,6 @@ | ||
//// [ES5For-of8.ts] | ||
function foo() { | ||
return { | ||
x: 0 | ||
}; | ||
} | ||
for(var _i = 0, _iter = [ | ||
"a", | ||
"b", | ||
"c" | ||
]; _i < _iter.length; _i++)foo().x = _iter[_i], foo().x; | ||
]; _i < _iter.length; _i++)_iter[_i]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,5 @@ | ||
//// [ES5For-of9.ts] | ||
function foo() { | ||
return { | ||
x: 0 | ||
}; | ||
} | ||
for(var _i = 0, _iter = []; _i < _iter.length; _i++){ | ||
foo().x = _iter[_i]; | ||
for(var _i1 = 0, _iter1 = []; _i1 < _iter1.length; _i1++)foo().x = _iter1[_i1], foo().x; | ||
_iter[_i]; | ||
for(var _i1 = 0, _iter1 = []; _i1 < _iter1.length; _i1++)_iter1[_i1]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 0 additions & 10 deletions
10
crates/swc/tests/tsc-references/genericCallWithFunctionTypedArguments.2.minified.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1 @@ | ||
//// [genericCallWithFunctionTypedArguments.ts] | ||
function foo(x) { | ||
return x(null); | ||
} | ||
foo(function(x) { | ||
return ""; | ||
}), foo(function(x) { | ||
return ""; | ||
}), foo(function(x) { | ||
return ""; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 2 additions & 5 deletions
7
crates/swc/tests/tsc-references/logicalAssignment10(target=es2015).2.minified.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
//// [logicalAssignment10.ts] | ||
var _obj, _ref, _ref1, _ref2, ref, ref1, count = 0, obj = {}; | ||
function incr() { | ||
return ++count; | ||
} | ||
null !== (ref = (_obj = obj)[_ref = incr()]) && void 0 !== ref || (_obj[_ref] = incr()), null !== (ref1 = (_ref1 = ({ | ||
null !== (ref = (_obj = obj)[_ref = ++count]) && void 0 !== ref || (_obj[_ref] = ++count), null !== (ref1 = (_ref1 = ({ | ||
obj | ||
}).obj)[_ref2 = incr()]) && void 0 !== ref1 || (_ref1[_ref2] = incr()); | ||
}).obj)[_ref2 = ++count]) && void 0 !== ref1 || (_ref1[_ref2] = ++count); |
7 changes: 2 additions & 5 deletions
7
crates/swc/tests/tsc-references/logicalAssignment10(target=es2020).2.minified.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
//// [logicalAssignment10.ts] | ||
var _obj, _ref, _ref1, _ref2, count = 0, obj = {}; | ||
function incr() { | ||
return ++count; | ||
} | ||
(_obj = obj)[_ref = incr()], _obj[_ref] = incr(), (_ref1 = ({ | ||
(_obj = obj)[_ref = ++count], _obj[_ref] = ++count, (_ref1 = ({ | ||
obj | ||
}).obj)[_ref2 = incr()], _ref1[_ref2] = incr(); | ||
}).obj)[_ref2 = ++count], _ref1[_ref2] = ++count; |
5 changes: 1 addition & 4 deletions
5
crates/swc/tests/tsc-references/logicalAssignment10(target=es2021).2.minified.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
//// [logicalAssignment10.ts] | ||
var count = 0, obj = {}; | ||
function incr() { | ||
return ++count; | ||
} | ||
const oobj = { | ||
obj | ||
}; | ||
obj[incr()] ??= incr(), oobj.obj[incr()] ??= incr(); | ||
obj[++count] ??= ++count, oobj.obj[++count] ??= ++count; |
5 changes: 1 addition & 4 deletions
5
crates/swc/tests/tsc-references/logicalAssignment10(target=es2022).2.minified.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
//// [logicalAssignment10.ts] | ||
var count = 0, obj = {}; | ||
function incr() { | ||
return ++count; | ||
} | ||
const oobj = { | ||
obj | ||
}; | ||
obj[incr()] ??= incr(), oobj.obj[incr()] ??= incr(); | ||
obj[++count] ??= ++count, oobj.obj[++count] ??= ++count; |
Oops, something went wrong.
b40d486
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benchmark
es/full/minify/libraries/antd
2015562752
ns/iter (± 28005356
)1834331506
ns/iter (± 39885588
)1.10
es/full/minify/libraries/d3
384817667
ns/iter (± 23995060
)418094059
ns/iter (± 14690679
)0.92
es/full/minify/libraries/echarts
1706567840
ns/iter (± 47308913
)1530692132
ns/iter (± 29775002
)1.11
es/full/minify/libraries/jquery
114085605
ns/iter (± 3107774
)103102409
ns/iter (± 4695676
)1.11
es/full/minify/libraries/lodash
137797128
ns/iter (± 13707766
)117076105
ns/iter (± 6573008
)1.18
es/full/minify/libraries/moment
74946097
ns/iter (± 15800127
)61189968
ns/iter (± 3739323
)1.22
es/full/minify/libraries/react
25100276
ns/iter (± 1373092
)20542165
ns/iter (± 2542483
)1.22
es/full/minify/libraries/terser
478940130
ns/iter (± 336414217
)347706361
ns/iter (± 24249666
)1.38
es/full/minify/libraries/three
627116485
ns/iter (± 24200158
)609781058
ns/iter (± 80759084
)1.03
es/full/minify/libraries/typescript
4218395148
ns/iter (± 204695328
)3542738000
ns/iter (± 116026114
)1.19
es/full/minify/libraries/victory
926313940
ns/iter (± 87392427
)842689386
ns/iter (± 58118087
)1.10
es/full/minify/libraries/vue
174570347
ns/iter (± 8157904
)162035246
ns/iter (± 32361176
)1.08
es/full/codegen/es3
41927
ns/iter (± 1199
)34212
ns/iter (± 655
)1.23
es/full/codegen/es5
41501
ns/iter (± 1364
)33959
ns/iter (± 1318
)1.22
es/full/codegen/es2015
41220
ns/iter (± 2111
)34331
ns/iter (± 1718
)1.20
es/full/codegen/es2016
41122
ns/iter (± 2960
)34011
ns/iter (± 800
)1.21
es/full/codegen/es2017
40630
ns/iter (± 2716
)34160
ns/iter (± 958
)1.19
es/full/codegen/es2018
41199
ns/iter (± 4842
)34482
ns/iter (± 1860
)1.19
es/full/codegen/es2019
41724
ns/iter (± 27729
)34339
ns/iter (± 2857
)1.22
es/full/codegen/es2020
41720
ns/iter (± 13576
)34066
ns/iter (± 1591
)1.22
es/full/all/es3
239405001
ns/iter (± 23327302
)203693619
ns/iter (± 15604482
)1.18
es/full/all/es5
226843921
ns/iter (± 21595910
)198572596
ns/iter (± 16426858
)1.14
es/full/all/es2015
183606446
ns/iter (± 17213743
)158778254
ns/iter (± 10797416
)1.16
es/full/all/es2016
182694742
ns/iter (± 14969074
)158913360
ns/iter (± 15748840
)1.15
es/full/all/es2017
183324645
ns/iter (± 13771465
)160350772
ns/iter (± 15680348
)1.14
es/full/all/es2018
176973367
ns/iter (± 11613859
)155373213
ns/iter (± 11634451
)1.14
es/full/all/es2019
179108311
ns/iter (± 16975959
)154751170
ns/iter (± 11488696
)1.16
es/full/all/es2020
174247112
ns/iter (± 20964067
)149262786
ns/iter (± 10724500
)1.17
es/full/parser
885301
ns/iter (± 76033
)733323
ns/iter (± 44394
)1.21
es/full/base/fixer
33082
ns/iter (± 1310
)27213
ns/iter (± 1544
)1.22
es/full/base/resolver_and_hygiene
120100
ns/iter (± 11597
)94711
ns/iter (± 3773
)1.27
serialization of ast node
253
ns/iter (± 14
)209
ns/iter (± 15
)1.21
serialization of serde
256
ns/iter (± 15
)210
ns/iter (± 3
)1.22
This comment was automatically generated by workflow using github-action-benchmark.