diff --git a/Makefile b/Makefile index b5101bbd91..9b490e8c66 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ MOCHA_CMD = node_modules/mocha/bin/_mocha export NODE_ENV = test -.PHONY: clean test test-cov test-clean lint test-travis test-spec test-browser publish bench build bootstrap +.PHONY: clean test test-cov test-clean lint test-travis test-spec test-browser publish build bootstrap build: mkdir -p dist @@ -27,12 +27,8 @@ build: clean: rm -rf coverage templates.json test/tmp dist -bench: - npm install es6-transpiler traceur esnext es6now jstransform - node node_modules/matcha/bin/_matcha - lint: - $(JSHINT_CMD) --reporter node_modules/jshint-stylish/stylish.js lib bin benchmark/index.js + $(JSHINT_CMD) --reporter node_modules/jshint-stylish/stylish.js lib bin test-clean: rm -rf test/tmp diff --git a/benchmark/fixtures/all.js b/benchmark/fixtures/all.js deleted file mode 100644 index 484e8b4682..0000000000 --- a/benchmark/fixtures/all.js +++ /dev/null @@ -1,99 +0,0 @@ -var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; -var obj = {}; -var foo = "foo"; -var bar = "bar"; - -// constants -const MULTIPLIER = 5; - -// classes -class Foo { - constructor() { - this.foo = "bar"; - } -} - -class Bar extends Foo { - constructor() { - super(); - } - - // default parameters - go(foo = "bar", bar = "foo") { - - } - - // not supported by jstransform - //get foo() { - // return this._foo; - //} - //set foo(val) { - // this._foo = val + " foo!"; - //} -} - -// arrow functions -arr.map(x => x * x); - -// block binding -for (let key in arr) { - let val = arr[key]; - console.log(key, val); -} - -// computed property names -obj = { - ["foo" + bar]: "foobar" -}; - -// destructuring -var [a, [b], c, d] = ["hello", [", ", "junk"], ["world"]]; -console.log(a + b + c); - -// array comprehension -// [for (i of [1, 2, 3]) i * i]; // not supported by es6now - -// for-of -for (var i of [1, 2, 3]) { - console.log(i * i); -} - -// property method assignment -obj = { - foo() { - return "foobar"; - }, - - get bar() { - return this._bar; - }, - - set bar(val) { - this._bar = val; - } -}; - -// property name shorthand -function f(x, y) { - return { x, y }; -} - -// rest parameters -function printList(name, ...items) { - console.log("list %s has the following items", name); - items.forEach(function (item) { - console.log(item); - }); -} - -// spread -function add(x, y) { - return x + y; -} -var numbers = [5, 10]; -add(...numbers); - -// template literals -var x = 5; -var y = 10; -console.log(`${x} + ${y} = ${x + y}`); diff --git a/benchmark/index.js b/benchmark/index.js deleted file mode 100644 index f0f820081d..0000000000 --- a/benchmark/index.js +++ /dev/null @@ -1,168 +0,0 @@ -Error.stackTraceLimit = Infinity; - -var jsTrans = require("jstransform"); -var traceur = require("traceur"); -//var es6tr = require("es6-transpiler"); -var es6now = require("es6now"); -//var esnext = require("esnext"); -var to5 = require("../lib/6to5"); - -//var uglify = require("uglify-js"); -var matcha = require("matcha"); -var path = require("path"); -var fs = require("fs"); -var _ = require("lodash"); - -var readResolve = function (filename) { - try { - filename = require.resolve(filename); - } catch (err) { - return null; - } - return fs.readFileSync(filename, "utf8"); -}; - -var getVersion = function (name) { - return require(name + "/package.json").version; -}; - -var jsTransVisitors = []; - -_.each([ - "arrow-function-visitors", "class-visitors", "destructuring-visitors", - "object-concise-method-visitors", "object-short-notation-visitors", - "rest-param-visitors", "template-visitors" -], function (name) { - var mod = require("jstransform/visitors/es6-" + name); - jsTransVisitors = jsTransVisitors.concat(mod.visitorList); -}); - - -var compilers = { - "6to5": { - version: getVersion(".."), - compile: function (code, filename) { - return to5.transform(code, { filename: filename }).code; - } - }, - - traceur: { - runtime: readResolve("traceur/bin/traceur-runtime.js"), - compile: function (code) { - return traceur.compile(code, { - modules: "commonjs", - experimental: true - }); - } - }, - - /*esnext: { - runtime: readResolve("esnext/node_modules/regenerator/runtime.js") || readResolve("regenerator/runtime.js"), - compile: function (code) { - return esnext.compile(code).code; - } - },*/ - - es6now: { - runtime: readResolve("es6now/runtime/ES6.js"), - compile: function (code) { - return es6now.translate(code); - } - }, - - /*"es6-transpiler": { - compile: function (code) { - var result = es6tr.run({ src: code }); - if (result.errors.length) throw new Error(result.join("; ")); - return result.src; - } - },*/ - - jstransform: { - compile: function (code) { - return jsTrans.transform(jsTransVisitors, code).code; - } - } -}; - -// versions - -//var uglifyTitle = "uglify v" + getVersion("uglify-js"); - -_.each(compilers, function (compiler, name) { - compiler.title = name + " v" + (compiler.version || getVersion(name)); -}); - -// - -var sizeBenchmark = function (code, loc, name, compiler) { - var log = function (output, title) { - title = [compiler.title].concat(title || []).join(" + "); - - var text; - var color; - if (output.stack) { - text = "error"; - color = "red"; - } else { - var kilo = (output.length / 1024).toFixed(2); - text = kilo + "KB"; - color = "cyan"; - } - - text = matcha.utils.color(matcha.utils.padBefore(text, 22), color); - - console.log(text, matcha.utils.color("ยป " + title, "gray")); - - if (output.stack) { - console.error(output.stack); - } - }; - - var go = function (getOutput, title) { - var code; - try { - code = getOutput(); - } catch (err) { - log(err, title); - return; - } - - log(code, title); - }; - - var output; - go(function () { - return output = compiler.compile(code, loc); - }); - if (!output) return; - - //go(function () { - // return uglify.minify(output, { fromString: true }).code; - //}, uglifyTitle); -}; - -// - -_.each(fs.readdirSync(__dirname + "/fixtures"), function (name) { - var alias = path.basename(name, path.extname(name)); - - suite(alias, function () { - set("delay", 0); - - var loc = __dirname + "/fixtures/" + name; - var code = fs.readFileSync(loc, "utf8"); - - before(function () { - _.each(compilers, function (compiler, name) { - sizeBenchmark(code, loc, name, compiler); - }); - }); - - _.each(compilers, function (compiler) { - bench(compiler.title, function () { - compiler.compile(code, loc); - }); - }); - }); -});