Skip to content

Commit 5a128fd

Browse files
authored
feat(bench): add terser. remove butternut (#883)
1 parent 2ed8531 commit 5a128fd

File tree

5 files changed

+62
-35
lines changed

5 files changed

+62
-35
lines changed

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
README.md

README.md

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -178,58 +178,59 @@ Add to your `.babelrc`'s plugins array.
178178
179179
Benchmark Results for react.js:
180180

181-
Input Size: 141.63kB
181+
Input Size: 54.79KB
182182

183-
Input Size (gzip): 33.66kB
183+
Input Size (gzip): 15.11KB
184184

185185
| minifier | output raw | raw win | gzip output | gzip win | parse time (ms) | minify time (ms) |
186186
| ----------------------- | ----------- | ------- | ----------- | -------- | --------------- | ---------------- |
187-
| **babel-minify** | 40.63kB | 71% | 13.33kB | 60% | 2.49 | 1905.17 |
188-
| **uglify** | **40.34kB** | **72%** | **13.12kB** | **61%** | **2.30** | **784.33** |
189-
| **closure-compiler** | 39.45kB | 72% | 13.25kB | 61% | 2.62 | 2519.02 |
190-
| **closure-compiler-js** | 47.23kB | 67% | 15.25kB | 55% | 3.76 | 6730.76 |
191-
| **butternut** | 41.94kB | 70% | 13.53kB | 60% | 2.33 | 275.20 |
187+
| **babel-minify** | 15.97KB | 71% | 6.08KB | 60% | 1.00 | 1039.06 |
188+
| **terser** | **15.65KB** | **71%** | **5.98KB** | **60%** | **0.93** | **532.19** |
189+
| **uglify** | 15.6KB | 72% | 6KB | 60% | 1.09 | 463.69 |
190+
| **closure-compiler** | 15.74KB | 71% | 6.04KB | 60% | 1.22 | 2361.41 |
191+
| **closure-compiler-js** | 18.21KB | 67% | 6.73KB | 55% | 1.08 | 3381.47 |
192192

193193
Benchmark Results for vue.js:
194194

195-
Input Size: 258.76kB
195+
Input Size: 282.52KB
196196

197-
Input Size (gzip): 71.01kB
197+
Input Size (gzip): 77.52KB
198198

199-
| minifier | output raw | raw win | gzip output | gzip win | parse time (ms) | minify time (ms) |
200-
| ----------------------- | ----------- | ------- | ----------- | -------- | --------------- | ---------------- |
201-
| **babel-minify** | 97.23kB | 62% | 36.09kB | 49% | 5.83 | 4986.36 |
202-
| **uglify** | 96.95kB | 63% | 35.99kB | 49% | 5.78 | 1446.37 |
203-
| **closure-compiler** | 95.29kB | 63% | 35.8kB | 50% | 6.28 | 3953.95 |
204-
| **closure-compiler-js** | 98.53kB | 62% | 36.73kB | 48% | 6.00 | 10221.88 |
199+
| minifier | output raw | raw win | gzip output | gzip win | parse time (ms) | minify time (ms) |
200+
| ----------------------- | ------------ | ------- | ----------- | -------- | --------------- | ---------------- |
201+
| **babel-minify** | 104.21KB | 63% | 38.71KB | 50% | 6.09 | 3538.30 |
202+
| **terser** | **103.12KB** | **63%** | **37.92KB** | **51%** | **6.42** | **1680.85** |
203+
| **uglify** | 102.71KB | 64% | 38.08KB | 51% | 6.59 | 1662.50 |
204+
| **closure-compiler** | 101.93KB | 64% | 38.6KB | 50% | 10.41 | 4413.06 |
205+
| **closure-compiler-js** | 105.18KB | 63% | 39.5KB | 49% | 6.79 | 12082.80 |
205206

206207
Benchmark Results for lodash.js:
207208

208-
Input Size: 526.94kB
209+
Input Size: 527.18KB
209210

210-
Input Size (gzip): 93.91kB
211+
Input Size (gzip): 94.04KB
211212

212213
| minifier | output raw | raw win | gzip output | gzip win | parse time (ms) | minify time (ms) |
213214
| ----------------------- | ----------- | ------- | ----------- | -------- | --------------- | ---------------- |
214-
| **babel-minify** | 69.14kB | 87% | 24.06kB | 74% | 8.37 | 4728.87 |
215-
| **uglify** | **68.58kB** | **87%** | **24kB** | **74%** | **27.20** | **2340.07** |
216-
| **closure-compiler** | 70.68kB | 87% | 24.11kB | 74% | 6.98 | 4718.42 |
217-
| **closure-compiler-js** | 73.14kB | 86% | 24.85kB | 74% | 6.57 | 8148.38 |
218-
| **butternut** | 72.06kB | 86% | 25.01kB | 73% | 6.95 | 514.93 |
215+
| **babel-minify** | 69.59KB | 87% | 24.37KB | 74% | 5.38 | 2587.27 |
216+
| **terser** | 68.66KB | 87% | 24.31KB | 74% | 6.41 | 1913.43 |
217+
| **uglify** | **68.15KB** | **87%** | **24.05KB** | **74%** | **5.89** | **2075.71** |
218+
| **closure-compiler** | 71.05KB | 87% | 24.19KB | 74% | 6.24 | 4119.43 |
219+
| **closure-compiler-js** | 73.51KB | 86% | 24.94KB | 73% | 5.17 | 9650.59 |
219220

220221
Benchmark Results for three.js:
221222

222-
Input Size: 1015.5kB
223+
Input Size: 1.05MB
223224

224-
Input Size (gzip): 202.89kB
225+
Input Size (gzip): 212.43KB
225226

226227
| minifier | output raw | raw win | gzip output | gzip win | parse time (ms) | minify time (ms) |
227228
| ----------------------- | ------------ | ------- | ------------ | -------- | --------------- | ---------------- |
228-
| **babel-minify** | 497.33kB | 51% | 126.74kB | 38% | 25.16 | 14465.92 |
229-
| **uglify** | **498.59kB** | **51%** | **125.66kB** | **38%** | **26.05** | **4419.97** |
230-
| **closure-compiler** | 495.7kB | 51% | 126.48kB | 38% | 34.40 | 10623.86 |
231-
| **closure-compiler-js** | 504.11kB | 50% | 127.84kB | 37% | 28.59 | 115045.71 |
232-
| **butternut** | 505.93kB | 50% | 127.09kB | 37% | 31.12 | 1349.77 |
229+
| **babel-minify** | 535.88KB | 50% | 134.66KB | 37% | 27.24 | 9988.57 |
230+
| **terser** | **536.16KB** | **50%** | **132.78KB** | **37%** | **28.39** | **3919.34** |
231+
| **uglify** | 533.42KB | 50% | 133.21KB | 37% | 26.15 | 4025.20 |
232+
| **closure-compiler** | 532.44KB | 51% | 134.41KB | 37% | 29.96 | 9029.19 |
233+
| **closure-compiler-js** | 543.08KB | 50% | 136.3KB | 36% | 24.36 | 95743.77 |
233234

234235
## Browser support
235236

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"prettier": "^1.12.1",
4949
"request": "^2.85.0",
5050
"rimraf": "^2.6.2",
51+
"terser": "^3.8.0",
5152
"through2": "^2.0.3",
5253
"uglify-js": "^3.3.23",
5354
"util.promisify": "^1.0.0"

scripts/benchmark.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
Error.stackTraceLimit = Infinity;
55

66
const uglify = require("uglify-js");
7+
const terser = require("terser");
78
const MDTable = require("markdown-table");
89
const CLITable = require("cli-table");
910
const child = require("child_process");
@@ -16,7 +17,6 @@ const path = require("path");
1617
const request = require("request");
1718
const program = require("commander");
1819
const compile = require("google-closure-compiler-js").compile;
19-
const butternut = require("butternut");
2020

2121
const ASSETS_DIR = path.join(__dirname, "benchmark_cache");
2222
const DEFAULT_ASSETS = {
@@ -56,10 +56,10 @@ class Benchmark {
5656
filename,
5757
items: [
5858
this.test(this["babel-minify"], code),
59+
this.test(this["terser"], code),
5960
this.test(this["uglify"], code),
6061
this.test(this["closure-compiler"], filename, false),
61-
this.test(this["closure-compiler-js"], code),
62-
this.test(this["butternut"], code)
62+
this.test(this["closure-compiler-js"], code)
6363
]
6464
};
6565

@@ -110,6 +110,9 @@ class Benchmark {
110110
uglify(code) {
111111
return uglify.minify(code).code;
112112
}
113+
terser(code) {
114+
return terser.minify(code).code;
115+
}
113116
"closure-compiler"(filename) {
114117
return child
115118
.execSync(
@@ -128,9 +131,7 @@ class Benchmark {
128131
const out = compile(flags);
129132
return out.compiledCode;
130133
}
131-
butternut(code) {
132-
return butternut.squash(code, { sourceMap: false }).code;
133-
}
134+
134135
getParseTime(code) {
135136
const start = process.hrtime();
136137
exports.DUMMY = new Function(code);

yarn.lock

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,6 +1211,10 @@ bser@^2.0.0:
12111211
dependencies:
12121212
node-int64 "^0.4.0"
12131213

1214+
buffer-from@^1.0.0:
1215+
version "1.1.0"
1216+
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.0.tgz#87fcaa3a298358e0ade6e442cfce840740d1ad04"
1217+
12141218
builtin-modules@^1.0.0:
12151219
version "1.1.1"
12161220
resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f"
@@ -1559,6 +1563,10 @@ commander@^2.9.0:
15591563
version "2.13.0"
15601564
resolved "https://registry.yarnpkg.com/commander/-/commander-2.13.0.tgz#6964bca67685df7c1f1430c584f07d7597885b9c"
15611565

1566+
commander@~2.16.0:
1567+
version "2.16.0"
1568+
resolved "https://registry.yarnpkg.com/commander/-/commander-2.16.0.tgz#f16390593996ceb4f3eeb020b31d78528f7f8a50"
1569+
15621570
compare-func@^1.3.1:
15631571
version "1.3.2"
15641572
resolved "https://registry.yarnpkg.com/compare-func/-/compare-func-1.3.2.tgz#99dd0ba457e1f9bc722b12c08ec33eeab31fa648"
@@ -6064,6 +6072,13 @@ source-map-support@^0.5.0:
60646072
dependencies:
60656073
source-map "^0.6.0"
60666074

6075+
source-map-support@~0.5.6:
6076+
version "0.5.6"
6077+
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.6.tgz#4435cee46b1aab62b8e8610ce60f788091c51c13"
6078+
dependencies:
6079+
buffer-from "^1.0.0"
6080+
source-map "^0.6.0"
6081+
60676082
source-map-url@^0.4.0:
60686083
version "0.4.0"
60696084
resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3"
@@ -6399,6 +6414,14 @@ tempfile@^1.1.1:
63996414
os-tmpdir "^1.0.0"
64006415
uuid "^2.0.1"
64016416

6417+
terser@^3.8.0:
6418+
version "3.8.0"
6419+
resolved "https://registry.yarnpkg.com/terser/-/terser-3.8.0.tgz#66a4f4f500d2c829faab840f318c49cc471d73ae"
6420+
dependencies:
6421+
commander "~2.16.0"
6422+
source-map "~0.6.1"
6423+
source-map-support "~0.5.6"
6424+
64026425
test-exclude@^4.1.1:
64036426
version "4.1.1"
64046427
resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-4.1.1.tgz#4d84964b0966b0087ecc334a2ce002d3d9341e26"

0 commit comments

Comments
 (0)