refactor(build): simplify and modularize
simplify: - use same html file for dart and JS - build benchmarks automatically when doing `gulp build` - centralize configuration modularize: - move all build tasks into separate node.js modules under `tools/build`. changes: - the `build` folder is now the `dist` folder Closes #284
This commit is contained in:
@ -1,63 +0,0 @@
|
||||
library benchmarks.benchpress;
|
||||
|
||||
import 'dart:js' as js;
|
||||
import 'dart:html';
|
||||
import 'dart:async';
|
||||
|
||||
// TODO: move the functionality of this module into benchpress and replace this
|
||||
// file with a Dart wrapper!
|
||||
|
||||
var _benchmarkNames = [];
|
||||
|
||||
_benchmarkId(index) {
|
||||
return "benchmark${index}";
|
||||
}
|
||||
|
||||
_useBenchmark(index) {
|
||||
var search = window.location.search;
|
||||
if (search.length > 0) {
|
||||
search = search.substring(1);
|
||||
}
|
||||
if (search.length > 0) {
|
||||
return search == _benchmarkId(index);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
_onLoad(callback) {
|
||||
var isReady = document.readyState == 'complete';
|
||||
if (isReady) {
|
||||
Timer.run(callback);
|
||||
} else {
|
||||
window.addEventListener('load', (event) => callback(), false);
|
||||
}
|
||||
}
|
||||
|
||||
_createBenchmarkMenu() {
|
||||
var div = document.createElement('div');
|
||||
div.innerHtml += '<h1>Benchmarks:</h1><a class="btn btn-default" href="?">All</a>';
|
||||
for (var i=0; i<_benchmarkNames.length; i++) {
|
||||
var activeClass = _useBenchmark(i) ? 'active' : '';
|
||||
div.innerHtml += '<a class="btn btn-default ${activeClass}" href="?${_benchmarkId(i)}">${_benchmarkNames[i]}</a>';
|
||||
}
|
||||
document.body.insertBefore(div, document.body.childNodes[0]);
|
||||
}
|
||||
|
||||
benchmark(name, stepsCreationCallback) {
|
||||
_benchmarkNames.add(name);
|
||||
if (_benchmarkNames.length == 2) {
|
||||
_onLoad(_createBenchmarkMenu);
|
||||
}
|
||||
if (_useBenchmark(_benchmarkNames.length-1)) {
|
||||
stepsCreationCallback();
|
||||
}
|
||||
}
|
||||
|
||||
benchmarkStep(name, callback) {
|
||||
var benchmarkName = _benchmarkNames[_benchmarkNames.length-1];
|
||||
js.context['benchmarkSteps'].add(new js.JsObject.jsify({
|
||||
"name": benchmarkName + '#' + name,
|
||||
"fn": new js.JsFunction.withThis((_) => callback())
|
||||
}));
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
// TODO: move the functionality of this module into benchpress itself!
|
||||
|
||||
var benchmarkNames = [];
|
||||
|
||||
function benchmarkId(index) {
|
||||
return 'benchmark' + index;
|
||||
}
|
||||
|
||||
function useBenchmark(index) {
|
||||
var search = window.location.search;
|
||||
if (search.length > 0) {
|
||||
search = search.substring(1);
|
||||
}
|
||||
if (search.length > 0) {
|
||||
return search == benchmarkId(index);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function onLoad(callback) {
|
||||
var isReady = document.readyState === 'complete';
|
||||
if (isReady) {
|
||||
window.setTimeout(callback);
|
||||
} else {
|
||||
window.addEventListener('load', callback, false);
|
||||
}
|
||||
}
|
||||
|
||||
function createBenchmarkMenu() {
|
||||
var div = document.createElement('div');
|
||||
div.innerHTML += '<h1>Benchmarks:</h1><a class="btn btn-default" href="?">All</a>';
|
||||
for (var i=0; i<benchmarkNames.length; i++) {
|
||||
var activeClass = useBenchmark(i) ? 'active' : '';
|
||||
div.innerHTML += ('<a class="btn btn-default '+activeClass+'" href="?'+benchmarkId(i)+'">'+benchmarkNames[i]+'</a>');
|
||||
}
|
||||
document.body.insertBefore(div, document.body.childNodes[0]);
|
||||
}
|
||||
|
||||
export function benchmark(name, stepsCreationCallback) {
|
||||
benchmarkNames.push(name);
|
||||
if (benchmarkNames.length === 2) {
|
||||
onLoad(createBenchmarkMenu);
|
||||
}
|
||||
if (useBenchmark(benchmarkNames.length-1)) {
|
||||
stepsCreationCallback();
|
||||
}
|
||||
}
|
||||
|
||||
export function benchmarkStep(name, callback) {
|
||||
var benchmarkName = benchmarkNames[benchmarkNames.length-1];
|
||||
window.benchmarkSteps.push({
|
||||
name: benchmarkName + '#' + name, fn: callback
|
||||
});
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
library benchmark;
|
||||
|
||||
import './change_detection_benchmark.dart' as cdb;
|
||||
import 'dart:js' as js;
|
||||
|
||||
main () {
|
||||
cdb.run();
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
System.import('benchmarks/change_detection/change_detection_benchmark').then(function (bm) {
|
||||
bm.run();
|
||||
}, console.log.bind(console));
|
@ -1,11 +0,0 @@
|
||||
module.exports = function(config) {
|
||||
config.set({
|
||||
scripts: [
|
||||
{src: '/js/traceur-runtime.js'},
|
||||
{src: '/js/es6-module-loader-sans-promises.src.js'},
|
||||
{src: '/js/extension-register.js'},
|
||||
{src: 'register_system.js'},
|
||||
{src: 'benchmark.js'}
|
||||
]
|
||||
});
|
||||
};
|
@ -3,7 +3,7 @@ import {Parser} from 'change_detection/parser/parser';
|
||||
import {Lexer} from 'change_detection/parser/lexer';
|
||||
import {reflector} from 'reflection/reflection';
|
||||
import {isPresent} from 'facade/lang';
|
||||
import {benchmark, benchmarkStep} from '../benchpress';
|
||||
import {benchmark, benchmarkStep} from 'benchpress/benchpress';
|
||||
|
||||
import {
|
||||
ChangeDetector,
|
||||
@ -153,7 +153,7 @@ function setUpChangeDetection() {
|
||||
return new ChangeDetector(parentRange);
|
||||
}
|
||||
|
||||
export function run () {
|
||||
export function main () {
|
||||
setUpReflector();
|
||||
|
||||
benchmark(`Baseline`, function () {
|
||||
|
@ -0,0 +1 @@
|
||||
$SCRIPTS$
|
1
modules/benchmarks/src/change_detection/main.js
Normal file
1
modules/benchmarks/src/change_detection/main.js
Normal file
@ -0,0 +1 @@
|
||||
export {main} from './change_detection_benchmark';
|
@ -1,11 +0,0 @@
|
||||
System.paths = {
|
||||
'core/*': '/js/core/lib/*.js',
|
||||
'change_detection/*': '/js/change_detection/lib/*.js',
|
||||
'facade/*': '/js/facade/lib/*.js',
|
||||
'di/*': '/js/di/lib/*.js',
|
||||
'rtts_assert/*': '/js/rtts_assert/lib/*.js',
|
||||
'test_lib/*': '/js/test_lib/lib/*.js',
|
||||
'benchmarks/*': '/js/benchmarks/lib/*.js',
|
||||
'reflection/*': '/js/reflection/lib/*.js'
|
||||
};
|
||||
register(System);
|
@ -1,9 +0,0 @@
|
||||
library compiler_benchmark;
|
||||
|
||||
import './selector_benchmark.dart' as sbm;
|
||||
import './compiler_benchmark.dart' as cbm;
|
||||
|
||||
main () {
|
||||
sbm.main();
|
||||
cbm.main();
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
Promise.all([
|
||||
System.import('benchmarks/compiler/selector_benchmark'),
|
||||
System.import('benchmarks/compiler/compiler_benchmark')
|
||||
]).then(function (benchmarks) {
|
||||
benchmarks.forEach(function(bm) {
|
||||
bm.main();
|
||||
});
|
||||
}, console.log.bind(console));
|
@ -1,11 +0,0 @@
|
||||
module.exports = function(config) {
|
||||
config.set({
|
||||
scripts: [
|
||||
{src: '/js/traceur-runtime.js'},
|
||||
{src: '/js/es6-module-loader-sans-promises.src.js'},
|
||||
{src: '/js/extension-register.js'},
|
||||
{src: 'register_system.js'},
|
||||
{src: 'benchmark.js'}
|
||||
]
|
||||
});
|
||||
};
|
@ -1,7 +1,7 @@
|
||||
import {benchmark, benchmarkStep} from '../benchpress';
|
||||
import {benchmark, benchmarkStep} from 'benchpress/benchpress';
|
||||
|
||||
import {DOM, document} from 'facade/dom';
|
||||
import {isBlank} from 'facade/lang';
|
||||
import {isBlank, Type} from 'facade/lang';
|
||||
import {MapWrapper} from 'facade/collection';
|
||||
import {AnnotatedType} from 'core/compiler/annotated_type';
|
||||
|
||||
@ -61,7 +61,7 @@ function setup() {
|
||||
});
|
||||
|
||||
reflector.registerGetters({
|
||||
"inter0": (a) => a.inter0, "inter1": (a) => a.inter1,
|
||||
"inter0": (a) => a.inter0, "inter1": (a) => a.inter1,
|
||||
"inter2": (a) => a.inter2, "inter3": (a) => a.inter3, "inter4": (a) => a.inter4,
|
||||
|
||||
"value0": (a) => a.value0, "value1": (a) => a.value1,
|
||||
@ -111,7 +111,7 @@ export function main() {
|
||||
benchmark(`instantiate 5*${COUNT} element with bindings`, function() {
|
||||
var template = loadTemplate('templateWithBindings', COUNT);
|
||||
var protoView = compiler.compileWithCache(null, annotatedComponent, template);
|
||||
var rootRecordRange = new ProtoRecordRange().instantiate(null, new Object());
|
||||
var rootRecordRange = new ProtoRecordRange().instantiate(null, null);
|
||||
|
||||
benchmarkStep('run', function() {
|
||||
var view = protoView.instantiate(null, null, null);
|
||||
|
@ -1,3 +1,5 @@
|
||||
$SCRIPTS$
|
||||
|
||||
<template id="templateNoBindings">
|
||||
<div class="class0 class1 class2 class3 class4 " nodir0="" attr0="value0" nodir1="" attr1="value1" nodir2="" attr2="value2" nodir3="" attr3="value3" nodir4="" attr4="value4">
|
||||
<div class="class0 class1 class2 class3 class4 " nodir0="" attr0="value0" nodir1="" attr1="value1" nodir2="" attr2="value2" nodir3="" attr3="value3" nodir4="" attr4="value4">
|
||||
|
7
modules/benchmarks/src/compiler/main.js
Normal file
7
modules/benchmarks/src/compiler/main.js
Normal file
@ -0,0 +1,7 @@
|
||||
import * as sbm from './selector_benchmark';
|
||||
import * as cbm from './compiler_benchmark';
|
||||
|
||||
export function main() {
|
||||
sbm.main();
|
||||
cbm.main();
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
System.paths = {
|
||||
'core/*': '/js/core/lib/*.js',
|
||||
'change_detection/*': '/js/change_detection/lib/*.js',
|
||||
'facade/*': '/js/facade/lib/*.js',
|
||||
'di/*': '/js/di/lib/*.js',
|
||||
'rtts_assert/*': '/js/rtts_assert/lib/*.js',
|
||||
'test_lib/*': '/js/test_lib/lib/*.js',
|
||||
'benchmarks/*': '/js/benchmarks/lib/*.js',
|
||||
'reflection/*': '/js/reflection/lib/*.js'
|
||||
};
|
||||
register(System);
|
@ -1,4 +1,4 @@
|
||||
import {benchmark, benchmarkStep} from '../benchpress';
|
||||
import {benchmark, benchmarkStep} from 'benchpress/benchpress';
|
||||
|
||||
import {SelectorMatcher} from "core/compiler/selector";
|
||||
import {CssSelector} from "core/compiler/selector";
|
||||
|
@ -1,11 +0,0 @@
|
||||
library injector_get_benchmark;
|
||||
|
||||
import './injector_instantiate_benchmark.dart' as b;
|
||||
import 'dart:js' as js;
|
||||
|
||||
main () {
|
||||
js.context['benchmarkSteps'].add(new js.JsObject.jsify({
|
||||
"name": "Injector.instantiate",
|
||||
"fn": new js.JsFunction.withThis((_) => b.run())
|
||||
}));
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
System.import('benchmarks/di/injector_get_benchmark').then(function (bm) {
|
||||
window.benchmarkSteps.push({name: 'Injector.get (token)', fn: bm.run});
|
||||
}, console.log.bind(console));
|
||||
|
||||
System.import('benchmarks/di/injector_get_by_key_benchmark').then(function (bm) {
|
||||
window.benchmarkSteps.push({name: 'Injector.get (key)', fn: bm.run});
|
||||
}, console.log.bind(console));
|
||||
|
||||
System.import('benchmarks/di/injector_get_child_benchmark').then(function (bm) {
|
||||
window.benchmarkSteps.push({name: 'Injector.get (grand x 5 child)', fn: bm.run});
|
||||
}, console.log.bind(console));
|
||||
|
||||
System.import('benchmarks/di/injector_instantiate_benchmark').then(function (bm) {
|
||||
window.benchmarkSteps.push({name: 'Injector.instantiate', fn: bm.run});
|
||||
}, console.log.bind(console));
|
@ -1,11 +0,0 @@
|
||||
module.exports = function(config) {
|
||||
config.set({
|
||||
scripts: [
|
||||
{src: '/js/traceur-runtime.js'},
|
||||
{src: '/js/es6-module-loader-sans-promises.src.js'},
|
||||
{src: '/js/extension-register.js'},
|
||||
{src: 'register_system.js'},
|
||||
{src: 'benchmark.js'}
|
||||
]
|
||||
});
|
||||
};
|
@ -0,0 +1 @@
|
||||
$SCRIPTS$
|
24
modules/benchmarks/src/di/main.js
Normal file
24
modules/benchmarks/src/di/main.js
Normal file
@ -0,0 +1,24 @@
|
||||
import * as injector_get_benchmark from './injector_get_benchmark';
|
||||
import * as injector_get_by_key_benchmark from './injector_get_by_key_benchmark';
|
||||
import * as injector_get_child_benchmark from './injector_get_child_benchmark';
|
||||
import * as injector_instantiate_benchmark from './injector_instantiate_benchmark';
|
||||
|
||||
import {benchmark, benchmarkStep} from 'benchpress/benchpress';
|
||||
|
||||
export function main() {
|
||||
benchmark(`Injector.get (token)`, function() {
|
||||
benchmarkStep('run', injector_get_benchmark.run);
|
||||
});
|
||||
|
||||
benchmark(`Injector.get (key)`, function() {
|
||||
benchmarkStep('run', injector_get_by_key_benchmark.run);
|
||||
});
|
||||
|
||||
benchmark(`Injector.get (grand x 5 child)`, function() {
|
||||
benchmarkStep('run', injector_get_child_benchmark.run);
|
||||
});
|
||||
|
||||
benchmark(`Injector.instantiate`, function() {
|
||||
benchmarkStep('run', injector_instantiate_benchmark.run);
|
||||
});
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
System.paths = {
|
||||
'core/*': '/js/core/lib/*.js',
|
||||
'change_detection/*': '/js/change_detection/lib/*.js',
|
||||
'facade/*': '/js/facade/lib/*.js',
|
||||
'di/*': '/js/di/lib/*.js',
|
||||
'rtts_assert/*': '/js/rtts_assert/lib/*.js',
|
||||
'test_lib/*': '/js/test_lib/lib/*.js',
|
||||
'benchmarks/*': '/js/benchmarks/lib/*.js',
|
||||
'reflection/*': '/js/reflection/lib/*.js'
|
||||
};
|
||||
register(System);
|
@ -1,23 +0,0 @@
|
||||
library element_injector_benchmark;
|
||||
|
||||
import './instantiate_benchmark.dart' as ib;
|
||||
import './instantiate_benchmark_codegen.dart' as ibc;
|
||||
import './instantiate_directive_benchmark.dart' as idb;
|
||||
import 'dart:js' as js;
|
||||
|
||||
main () {
|
||||
js.context['benchmarkSteps'].add(new js.JsObject.jsify({
|
||||
"name": "ElementInjector.instantiate + instantiateDirectives",
|
||||
"fn": new js.JsFunction.withThis((_) => ib.run())
|
||||
}));
|
||||
|
||||
js.context['benchmarkSteps'].add(new js.JsObject.jsify({
|
||||
"name": "ElementInjector.instantiateDirectives",
|
||||
"fn": new js.JsFunction.withThis((_) => idb.run())
|
||||
}));
|
||||
|
||||
js.context['benchmarkSteps'].add(new js.JsObject.jsify({
|
||||
"name": "ElementInjector.instantiate + instantiateDirectives (codegen)",
|
||||
"fn": new js.JsFunction.withThis((_) => ibc.run())
|
||||
}));
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
System.import('benchmarks/element_injector/instantiate_benchmark').then(function (bm) {
|
||||
window.benchmarkSteps.push({name: 'ElementInjector.instantiate + instantiateDirectives', fn: bm.run});
|
||||
}, console.log.bind(console));
|
||||
|
||||
System.import('benchmarks/element_injector/instantiate_directive_benchmark').then(function (bm) {
|
||||
window.benchmarkSteps.push({name: 'ElementInjector.instantiateDirectives', fn: bm.run});
|
||||
}, console.log.bind(console));
|
||||
|
||||
System.import('benchmarks/element_injector/instantiate_benchmark_codegen').then(function (bm) {
|
||||
window.benchmarkSteps.push({name: 'ElementInjector.instantiate + instantiateDirectives (codegen)', fn: bm.run});
|
||||
}, console.log.bind(console));
|
@ -1,11 +0,0 @@
|
||||
module.exports = function(config) {
|
||||
config.set({
|
||||
scripts: [
|
||||
{src: '/js/traceur-runtime.js'},
|
||||
{src: '/js/es6-module-loader-sans-promises.src.js'},
|
||||
{src: '/js/extension-register.js'},
|
||||
{src: 'register_system.js'},
|
||||
{src: 'benchmark.js'}
|
||||
]
|
||||
});
|
||||
};
|
@ -0,0 +1 @@
|
||||
$SCRIPTS$
|
19
modules/benchmarks/src/element_injector/main.js
Normal file
19
modules/benchmarks/src/element_injector/main.js
Normal file
@ -0,0 +1,19 @@
|
||||
import * as instantiate_benchmark from './instantiate_benchmark';
|
||||
import * as instantiate_directive_benchmark from './instantiate_directive_benchmark';
|
||||
import * as instantiate_benchmark_codegen from './instantiate_benchmark_codegen';
|
||||
|
||||
import {benchmark, benchmarkStep} from 'benchpress/benchpress';
|
||||
|
||||
export function main() {
|
||||
benchmark(`ElementInjector.instantiate + instantiateDirectives`, function() {
|
||||
benchmarkStep('run', instantiate_benchmark.run);
|
||||
});
|
||||
|
||||
benchmark(`ElementInjector.instantiateDirectives`, function() {
|
||||
benchmarkStep('run', instantiate_directive_benchmark.run);
|
||||
});
|
||||
|
||||
benchmark(`ElementInjector.instantiate + instantiateDirectives (codegen)`, function() {
|
||||
benchmarkStep('run', instantiate_benchmark_codegen.run);
|
||||
});
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
System.paths = {
|
||||
'core/*': '/js/core/lib/*.js',
|
||||
'change_detection/*': '/js/change_detection/lib/*.js',
|
||||
'facade/*': '/js/facade/lib/*.js',
|
||||
'di/*': '/js/di/lib/*.js',
|
||||
'rtts_assert/*': '/js/rtts_assert/lib/*.js',
|
||||
'test_lib/*': '/js/test_lib/lib/*.js',
|
||||
'benchmarks/*': '/js/benchmarks/lib/*.js',
|
||||
'reflection/*': '/js/reflection/lib/*.js'
|
||||
};
|
||||
register(System);
|
Reference in New Issue
Block a user