refactor(benchmarks): add cloud reporter, add params
- adds console and cloud reporter (via Google BigQuery). - makes parameters of tests explicit and modifiable. - removes `detect` and `ignoreGc` mode from benchpress as these can result in unstable numbers.
This commit is contained in:
@ -2,8 +2,19 @@
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<button id="compileWithBindings">Compile template with bindings</button>
|
||||
<button id="compileNoBindings">Compile template without bindings</button>
|
||||
<h2>Params</h2>
|
||||
<form>
|
||||
Elements:
|
||||
<input type="number" name="elements" placeholder="elements" value="150">
|
||||
<br>
|
||||
<button>Apply</button>
|
||||
</form>
|
||||
|
||||
<h2>Actions</h2>
|
||||
<p>
|
||||
<button id="compileWithBindings">CompileWithBindings</button>
|
||||
<button id="compileNoBindings">CompileNoBindings</button>
|
||||
</p>
|
||||
|
||||
<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">
|
||||
|
@ -13,8 +13,7 @@ import {Decorator} from 'core/annotations/annotations';
|
||||
import {TemplateConfig} from 'core/annotations/template_config';
|
||||
|
||||
import {reflector} from 'reflection/reflection';
|
||||
|
||||
var COUNT = 30;
|
||||
import {getIntParameter, bindAction} from 'e2e_test_lib/benchmark_util';
|
||||
|
||||
function setupReflector() {
|
||||
reflector.registerType(BenchmarkComponent, {
|
||||
@ -75,31 +74,33 @@ function setupReflector() {
|
||||
}
|
||||
|
||||
export function main() {
|
||||
var count = getIntParameter('elements');
|
||||
|
||||
setupReflector();
|
||||
var reader = new DirectiveMetadataReader();
|
||||
var cache = new CompilerCache();
|
||||
var compiler = new Compiler(null, reader, new Parser(new Lexer()), cache);
|
||||
var annotatedComponent = reader.read(BenchmarkComponent);
|
||||
|
||||
var templateNoBindings = loadTemplate('templateNoBindings', COUNT);
|
||||
var templateWithBindings = loadTemplate('templateWithBindings', COUNT);
|
||||
var templateNoBindings = loadTemplate('templateNoBindings', count);
|
||||
var templateWithBindings = loadTemplate('templateWithBindings', count);
|
||||
|
||||
function compileNoBindings(_) {
|
||||
function compileNoBindings() {
|
||||
// Need to clone every time as the compiler might modify the template!
|
||||
var cloned = DOM.clone(templateNoBindings);
|
||||
cache.clear();
|
||||
compiler.compileAllLoaded(null, annotatedComponent, cloned);
|
||||
}
|
||||
|
||||
function compileWithBindings(_) {
|
||||
function compileWithBindings() {
|
||||
// Need to clone every time as the compiler might modify the template!
|
||||
var cloned = DOM.clone(templateWithBindings);
|
||||
cache.clear();
|
||||
compiler.compileAllLoaded(null, annotatedComponent, cloned);
|
||||
}
|
||||
|
||||
DOM.on(DOM.querySelector(document, '#compileNoBindings'), 'click', compileNoBindings);
|
||||
DOM.on(DOM.querySelector(document, '#compileWithBindings'), 'click', compileWithBindings);
|
||||
bindAction('#compileNoBindings', compileNoBindings);
|
||||
bindAction('#compileWithBindings', compileWithBindings);
|
||||
}
|
||||
|
||||
function loadTemplate(templateId, repeatCount) {
|
||||
|
@ -2,9 +2,20 @@
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h2>Params</h2>
|
||||
<form>
|
||||
Selectors:
|
||||
<input type="number" name="selectors" placeholder="selectors" value="10000">
|
||||
<br>
|
||||
<button>Apply</button>
|
||||
</form>
|
||||
|
||||
<h2>Actions</h2>
|
||||
<p>
|
||||
<button id="parse">Selector.parse</button>
|
||||
<button id="addSelectable">Selector.addSelectable</button>
|
||||
<button id="match">Selector.match</button>
|
||||
</p>
|
||||
|
||||
$SCRIPTS$
|
||||
|
||||
|
@ -1,46 +1,45 @@
|
||||
import {document, DOM} from 'facade/dom';
|
||||
|
||||
import {SelectorMatcher} from "core/compiler/selector";
|
||||
import {CssSelector} from "core/compiler/selector";
|
||||
import {StringWrapper, Math} from 'facade/lang';
|
||||
import {ListWrapper} from 'facade/collection';
|
||||
|
||||
var COUNT = 1000;
|
||||
import {getIntParameter, bindAction} from 'e2e_test_lib/benchmark_util';
|
||||
|
||||
export function main() {
|
||||
var count = getIntParameter('selectors');
|
||||
|
||||
var fixedMatcher;
|
||||
var fixedSelectorStrings = [];
|
||||
var fixedSelectors = [];
|
||||
for (var i=0; i<COUNT; i++) {
|
||||
for (var i=0; i<count; i++) {
|
||||
ListWrapper.push(fixedSelectorStrings, randomSelector());
|
||||
}
|
||||
for (var i=0; i<COUNT; i++) {
|
||||
for (var i=0; i<count; i++) {
|
||||
ListWrapper.push(fixedSelectors, CssSelector.parse(fixedSelectorStrings[i]));
|
||||
}
|
||||
fixedMatcher = new SelectorMatcher();
|
||||
for (var i=0; i<COUNT; i++) {
|
||||
for (var i=0; i<count; i++) {
|
||||
fixedMatcher.addSelectable(fixedSelectors[i], i);
|
||||
}
|
||||
|
||||
function parse(_) {
|
||||
function parse() {
|
||||
var result = [];
|
||||
for (var i=0; i<COUNT; i++) {
|
||||
for (var i=0; i<count; i++) {
|
||||
ListWrapper.push(result, CssSelector.parse(fixedSelectorStrings[i]));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function addSelectable(_) {
|
||||
function addSelectable() {
|
||||
var matcher = new SelectorMatcher();
|
||||
for (var i=0; i<COUNT; i++) {
|
||||
for (var i=0; i<count; i++) {
|
||||
matcher.addSelectable(fixedSelectors[i], i);
|
||||
}
|
||||
return matcher;
|
||||
}
|
||||
|
||||
function match(_) {
|
||||
function match() {
|
||||
var matchCount = 0;
|
||||
for (var i=0; i<COUNT; i++) {
|
||||
for (var i=0; i<count; i++) {
|
||||
fixedMatcher.match(fixedSelectors[i], (selected) => {
|
||||
matchCount += selected;
|
||||
});
|
||||
@ -48,9 +47,9 @@ export function main() {
|
||||
return matchCount;
|
||||
}
|
||||
|
||||
DOM.on(DOM.querySelector(document, '#parse'), 'click', parse);
|
||||
DOM.on(DOM.querySelector(document, '#addSelectable'), 'click', addSelectable);
|
||||
DOM.on(DOM.querySelector(document, '#match'), 'click', match);
|
||||
bindAction('#parse', parse);
|
||||
bindAction('#addSelectable', addSelectable);
|
||||
bindAction('#match', match);
|
||||
}
|
||||
|
||||
function randomSelector() {
|
||||
|
Reference in New Issue
Block a user