refactor(perf): e2e tests and benchpress should be written in es6

This commit is contained in:
Tobias Bosch 2015-01-06 15:19:22 -08:00
parent 373fd7d04a
commit fe2a09bc7f
17 changed files with 96 additions and 20 deletions

View File

@ -6,6 +6,8 @@
1. `npm install` 1. `npm install`
2. `npm install -g gulp karma karma-cli` 2. `npm install -g gulp karma karma-cli`
3. `npm install -g protractor`
4. `webdriver-manager update`
3. Optionally install Dart SDK (only if you plan on building Dart applications) 3. Optionally install Dart SDK (only if you plan on building Dart applications)
1. [Install the Dart SDK](https://www.dartlang.org/tools/sdk/) 1. [Install the Dart SDK](https://www.dartlang.org/tools/sdk/)
2. [Add the Dart SDK's `bin` directory to your system path](https://www.dartlang.org/tools/pub/installing.html) 2. [Add the Dart SDK's `bin` directory to your system path](https://www.dartlang.org/tools/pub/installing.html)
@ -34,18 +36,24 @@
2. `gulp clean` -> cleans the `dist` folder 2. `gulp clean` -> cleans the `dist` folder
### Tests: ### Unit tests:
1. `karma start karma-js.conf.js`: JS tests 1. `karma start karma-js.conf.js`: JS tests
2. `karma start karma-dart.conf.js`: Dart tests 2. `karma start karma-dart.conf.js`: Dart tests
Notes for all tests: Notes for transpiler tests:
The karma preprocessor is setup in a way so that after every test run The karma preprocessor is setup in a way so that after every test run
the transpiler is reloaded. With that it is possible to make changes the transpiler is reloaded. With that it is possible to make changes
to the preprocessor and run the tests without exiting karma to the preprocessor and run the tests without exiting karma
(just touch a test file that you would like to run). (just touch a test file that you would like to run).
### Performance tests
1. `gulp build.cjs` (builds benchpress and tests into `dist/cjs` folder)
2. `protractor protractor-perf-js.conf.js`: JS performance tests
3. `protractor protractor-perf-dart2js.conf.js`: Dart2JS performance tests
### Examples: ### Examples:
To see the examples, first build the project as described above. To see the examples, first build the project as described above.

View File

@ -27,6 +27,18 @@ var _COMPILER_CONFIG_JS_DEFAULT = {
modules: 'instantiate' modules: 'instantiate'
}; };
var CJS_COMPILER_OPTIONS = {
sourceMaps: true,
annotations: false, // parse annotations
types: false, // parse types
// TODO(tbosch): Right now, traceur generates imports that
// rely on absolute paths. This is why we are not using this...
script: true, // parse as a script
memberVariables: false, // parse class fields
typeAssertions: false,
modules: null // not needed
};
var _HTLM_DEFAULT_SCRIPTS_JS = [ var _HTLM_DEFAULT_SCRIPTS_JS = [
{src: '/deps/traceur-runtime.js', mimeType: 'text/javascript'}, {src: '/deps/traceur-runtime.js', mimeType: 'text/javascript'},
{src: '/rtts_assert/lib/rtts_assert.js', mimeType: 'text/javascript'}, {src: '/rtts_assert/lib/rtts_assert.js', mimeType: 'text/javascript'},
@ -51,7 +63,12 @@ var CONFIG = {
prod: 'dist/js/prod', prod: 'dist/js/prod',
dart2js: 'dist/js/dart2js' dart2js: 'dist/js/dart2js'
}, },
dart: 'dist/dart' dart: 'dist/dart',
cjs: {
all: 'dist/cjs',
tools: 'dist/cjs/tools',
e2eTest: 'dist/cjs/e2e_test'
}
}, },
srcFolderMapping: { srcFolderMapping: {
'default': 'lib', 'default': 'lib',
@ -72,12 +89,20 @@ var CONFIG = {
}, },
transpile: { transpile: {
src: { src: {
js: ['modules/**/*.js', 'modules/**/*.es6', '!modules/**/perf/**/*'], js: ['modules/**/*.js', 'modules/**/*.es6', '!modules/**/e2e_test/**'],
dart: ['modules/**/*.js', '!modules/**/perf/**/*'] dart: ['modules/**/*.js', '!modules/**/e2e_test/**'],
cjs: {
tools: ['tools/**/*.es6', '!tools/transpiler/**'],
e2eTest: ['modules/**/e2e_test/**/*.es6']
}
}, },
copy: { copy: {
js: ['modules/**/*.es5', '!modules/**/perf/**/*'], js: ['modules/**/*.es5', '!modules/**/e2e_test/**'],
dart: ['modules/**/*.dart', '!modules/**/perf/**/*'] dart: ['modules/**/*.dart', '!modules/**/e2e_test/**'],
cjs: {
tools: ['tools/**/*.es5', '!tools/transpiler/**'],
e2eTest: ['modules/**/e2e_test/**/*.es5']
}
}, },
options: { options: {
js: { js: {
@ -96,7 +121,8 @@ var CONFIG = {
script: false, // parse as a module script: false, // parse as a module
memberVariables: true, // parse class fields memberVariables: true, // parse class fields
outputLanguage: 'dart' outputLanguage: 'dart'
} },
cjs: CJS_COMPILER_OPTIONS
} }
}, },
html: { html: {
@ -134,6 +160,11 @@ gulp.task('build/clean.dart', clean(gulp, gulpPlugins, {
path: CONFIG.dest.dart path: CONFIG.dest.dart
})); }));
gulp.task('build/clean.cjs', clean(gulp, gulpPlugins, {
path: CONFIG.dest.cjs.all
}));
// ------------ // ------------
// deps // deps
@ -177,6 +208,28 @@ gulp.task('build/transpile.dart', transpile(gulp, gulpPlugins, {
srcFolderMapping: CONFIG.srcFolderMapping srcFolderMapping: CONFIG.srcFolderMapping
})); }));
gulp.task('build/transpile/tools.cjs', transpile(gulp, gulpPlugins, {
src: CONFIG.transpile.src.cjs.tools,
copy: CONFIG.transpile.copy.cjs.tools,
dest: CONFIG.dest.cjs.tools,
outputExt: 'js',
options: CONFIG.transpile.options.cjs,
srcFolderMapping: {
'default': 'src'
}
}));
gulp.task('build/transpile/e2eTest.cjs', transpile(gulp, gulpPlugins, {
src: CONFIG.transpile.src.cjs.e2eTest,
copy: CONFIG.transpile.copy.cjs.e2eTest,
dest: CONFIG.dest.cjs.e2eTest,
outputExt: 'js',
options: CONFIG.transpile.options.cjs,
srcFolderMapping: {
'default': 'src'
}
}));
// ------------ // ------------
// html // html
@ -339,8 +392,14 @@ gulp.task('build.js.prod', function() {
); );
}); });
gulp.task('build.cjs', function() {
return runSequence(
['build/transpile/tools.cjs', 'build/transpile/e2eTest.cjs']
);
});
gulp.task('build.js', ['build.js.dev', 'build.js.prod']); gulp.task('build.js', ['build.js.dev', 'build.js.prod']);
gulp.task('clean', ['build/clean.js', 'build/clean.dart']); gulp.task('clean', ['build/clean.js', 'build/clean.dart', 'build/clean.cjs']);
gulp.task('build', ['build.js', 'build.dart']); gulp.task('build', ['build.js', 'build.dart', 'build.cjs']);

View File

@ -1,5 +1,5 @@
"use strict"; "use strict";
var benchpress = require('../../../../tools/benchpress/benchpress.js'); var benchpress = require('../../../tools/benchpress/index.js');
describe('ng2 change detection benchmark', function () { describe('ng2 change detection benchmark', function () {

View File

@ -1,5 +1,5 @@
"use strict"; "use strict";
var benchpress = require('../../../../tools/benchpress/benchpress.js'); var benchpress = require('../../../tools/benchpress/index.js');
describe('ng2 compiler benchmark', function () { describe('ng2 compiler benchmark', function () {

View File

@ -1,5 +1,5 @@
"use strict"; "use strict";
var benchpress = require('../../../../tools/benchpress/benchpress.js'); var benchpress = require('../../../tools/benchpress/index.js');
describe('ng2 di benchmark', function () { describe('ng2 di benchmark', function () {

View File

@ -1,5 +1,5 @@
"use strict"; "use strict";
var benchpress = require('../../../../tools/benchpress/benchpress.js'); var benchpress = require('../../../tools/benchpress/index.js');
describe('ng2 element injector benchmark', function () { describe('ng2 element injector benchmark', function () {

View File

@ -1,5 +1,5 @@
"use strict"; "use strict";
var benchpress = require('../../../../tools/benchpress/benchpress.js'); var benchpress = require('../../../tools/benchpress/index.js');
describe('ng2 tree benchmark', function () { describe('ng2 tree benchmark', function () {

View File

@ -1,5 +1,5 @@
"use strict"; "use strict";
var benchpress = require('../../../../tools/benchpress/benchpress.js'); var benchpress = require('../../../tools/benchpress/index.js');
describe('ng1.x compiler benchmark', function () { describe('ng1.x compiler benchmark', function () {

View File

@ -1,5 +1,5 @@
"use strict"; "use strict";
var benchpress = require('../../../../tools/benchpress/benchpress.js'); var benchpress = require('../../../tools/benchpress/index.js');
describe('ng1.x tree benchmark', function () { describe('ng1.x tree benchmark', function () {

View File

@ -1,6 +1,9 @@
// load traceur runtime as our tests are written in es6
require('traceur/bin/traceur-runtime.js');
var config = exports.config = { var config = exports.config = {
specs: ['modules/*/test/**/*_perf.js'], specs: ['dist/cjs/**/*_perf.js'],
params: { params: {
timeBenchmark: { timeBenchmark: {

View File

@ -1,5 +1,5 @@
var timeBenchmark = require('./time_benchmark'); var timeBenchmark = require('./src/time_benchmark');
var tools = require('./tools'); var tools = require('./src/tools');
module.exports = { module.exports = {
runTimeBenchmark: timeBenchmark.runTimeBenchmark, runTimeBenchmark: timeBenchmark.runTimeBenchmark,

View File

@ -0,0 +1,6 @@
module.exports = function(gulp, plugins, config) {
return function(done) {
del(config.path, done);
};
};