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,7 +0,0 @@
|
||||
Promise.all([
|
||||
System.import('benchmarks_external/compiler/compiler_benchmark_ng13')
|
||||
]).then(function (benchmarks) {
|
||||
benchmarks.forEach(function(bm) {
|
||||
bm.main();
|
||||
});
|
||||
}, console.log.bind(console));
|
@ -1,12 +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: 'https://ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.js'},
|
||||
{src: 'benchmark.js'}
|
||||
]
|
||||
});
|
||||
};
|
@ -1,6 +1,6 @@
|
||||
import 'package:angular/angular.dart';
|
||||
import 'package:angular/application_factory_static.dart';
|
||||
import '../benchpress.dart';
|
||||
import 'package:benchpress/benchpress.dart';
|
||||
import 'dart:html';
|
||||
|
||||
var COUNT = 30;
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {benchmark, benchmarkStep} from '../benchpress';
|
||||
import {benchmark, benchmarkStep} from 'benchpress/benchpress';
|
||||
|
||||
var COUNT = 30;
|
||||
var $compile;
|
||||
|
1
modules/benchmarks_external/src/compiler/main.es6
Normal file
1
modules/benchmarks_external/src/compiler/main.es6
Normal file
@ -0,0 +1 @@
|
||||
export {main} from './compiler_benchmark_ng13';
|
@ -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">
|
||||
|
@ -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_external/*': '/js/benchmarks_external/lib/*.js',
|
||||
'reflection/*': '/js/reflection/lib/*.js'
|
||||
};
|
||||
register(System);
|
Reference in New Issue
Block a user