From 0744566c4b32f2d957ee9935498b82e401fa008e Mon Sep 17 00:00:00 2001 From: Vignesh Shanmugam Date: Tue, 5 Jun 2018 13:16:38 +0200 Subject: [PATCH] Add babel-minify benchmark Closes #55 and #56. --- README.md | 1 + docs/in-depth.md | 11 ++++++++--- package.json | 1 + src/babel-minify-benchmark.js | 25 +++++++++++++++++++++++++ src/babel-minify-benchmarkt.test.js | 8 ++++++++ src/cli-flags-helper.js | 1 + 6 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 src/babel-minify-benchmark.js create mode 100644 src/babel-minify-benchmarkt.test.js diff --git a/README.md b/README.md index f2319929..702724ec 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ Running Web Tooling Benchmark 0.3.2... -------------------------------------- acorn: 6.06 runs/sec babel: 6.23 runs/sec + babel-minify: 4.88 runs/sec babylon: 6.73 runs/sec buble: 5.19 runs/sec chai: 9.60 runs/sec diff --git a/docs/in-depth.md b/docs/in-depth.md index a31466af..043f9ff3 100644 --- a/docs/in-depth.md +++ b/docs/in-depth.md @@ -38,6 +38,12 @@ Note that this explicitly excludes the [Babylon](https://github.com/babel/babylo and only measures the throughput of the actual transformations. The parser is tested separately by the `babylon` benchmark below. +## babel-minify + +[Babel Minify](https://github.com/babel/minify) is an ES2015+ aware minifier based on the Babel toolchain. It is written as a set of Babel plugins. + +This benchmark stresses the babel minifier on the (concatenated) JavaScript source for the ES2015 test in the [Speedometer](https://browserbench.org/Speedometer) 2.0 benchmark. + ## babylon [Babylon](https://github.com/babel/babylon) is the frontend for the Babel transpiler and @@ -198,9 +204,8 @@ compressor and beautifier toolkit, which is commonly used to minimize JavaScript bundles. This benchmark runs the UglifyJS minifier on the (concatenated) JavaScript source for -the ES2015 test in the [Speedometer](https://browserbench.org/Speedometer) 2.0 benchmark. +the ES2015 test in the [Lodash](https://lodash.com) module. ## uglify-es -This benchmark stresses the new ES2015 and beyond minifier using the 196KiB -ES2015 module containing the untranspiled [Vue](https://github.com/vuejs/vue) bundle. +This benchmark stresses the new ES2015 and beyond minifier on the (concatenated) JavaScript source for the ES2015 test in the [Speedometer](https://browserbench.org/Speedometer) 2.0 benchmark. diff --git a/package.json b/package.json index a4ba26ce..b4cd0331 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "@babel/standalone": "7.0.0-beta.32", "acorn": "5.5.3", "autoprefixer": "8.2.0", + "babel-minify": "0.4.3", "babylon": "7.0.0-beta.32", "benchmark": "^2.1.4", "buble": "0.19.3", diff --git a/src/babel-minify-benchmark.js b/src/babel-minify-benchmark.js new file mode 100644 index 00000000..5576ccf8 --- /dev/null +++ b/src/babel-minify-benchmark.js @@ -0,0 +1,25 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +const babelMinify = require("babel-minify"); +const fs = require("fs"); + +const payloads = [ + { + name: "speedometer-es2015-test-2.0.js", + options: {} + } +].map(({ name, options }) => ({ + payload: fs.readFileSync(`third_party/${name}`, "utf8"), + options +})); + +module.exports = { + name: "babel-minify", + fn() { + return payloads.map(({ payload, options }) => + babelMinify(payload, options) + ); + } +}; diff --git a/src/babel-minify-benchmarkt.test.js b/src/babel-minify-benchmarkt.test.js new file mode 100644 index 00000000..b9e7eda3 --- /dev/null +++ b/src/babel-minify-benchmarkt.test.js @@ -0,0 +1,8 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +const babelMinifyBenchmark = require("./babel-minify-benchmark"); + +it("babel-minify-benchmark runs to completion", () => + void babelMinifyBenchmark.fn()); diff --git a/src/cli-flags-helper.js b/src/cli-flags-helper.js index 0802aa75..902ee7c6 100644 --- a/src/cli-flags-helper.js +++ b/src/cli-flags-helper.js @@ -1,6 +1,7 @@ const targetList = new Set([ "acorn", "babel", + "babel-minify", "babylon", "buble", "chai",