feat(benchpress): add custom user metric to benchpress
This is a continuation of #7440 (@jeffbcross). Closes #9229
This commit is contained in:
committed by
Tobias Bosch
parent
1eaa193c51
commit
6686bc62f6
@@ -0,0 +1,3 @@
|
||||
library benchmarks.e2e_test.page_load_perf;
|
||||
|
||||
main() {}
|
||||
@@ -0,0 +1,37 @@
|
||||
import {verifyNoBrowserErrors} from 'angular2/src/testing/perf_util';
|
||||
|
||||
describe('ng2 largetable benchmark', function() {
|
||||
|
||||
var URL = 'benchmarks/src/page_load/page_load.html';
|
||||
var runner = global['benchpressRunner'];
|
||||
|
||||
afterEach(verifyNoBrowserErrors);
|
||||
|
||||
|
||||
it('should log the load time', function(done) {
|
||||
runner.sample({
|
||||
id: 'loadTime',
|
||||
prepare: null,
|
||||
microMetrics: null,
|
||||
userMetrics:
|
||||
{loadTime: 'The time in milliseconds to bootstrap', someConstant: 'Some constant'},
|
||||
bindings: [
|
||||
benchpress.bind(benchpress.SizeValidator.SAMPLE_SIZE)
|
||||
.toValue(2),
|
||||
benchpress.bind(benchpress.RegressionSlopeValidator.SAMPLE_SIZE).toValue(2),
|
||||
benchpress.bind(benchpress.RegressionSlopeValidator.METRIC).toValue('someConstant')
|
||||
],
|
||||
execute: () => { browser.get(URL); }
|
||||
})
|
||||
.then(report => {
|
||||
expect(report.completeSample.map(val => val.values.someConstant)
|
||||
.every(v => v === 1234567890))
|
||||
.toBe(true);
|
||||
expect(report.completeSample.map(val => val.values.loadTime)
|
||||
.filter(t => typeof t === 'number' && t > 0)
|
||||
.length)
|
||||
.toBeGreaterThan(1);
|
||||
})
|
||||
.then(done);
|
||||
});
|
||||
});
|
||||
@@ -26,6 +26,7 @@ transformers:
|
||||
- web/src/naive_infinite_scroll/index.dart
|
||||
- web/src/static_tree/tree_benchmark.dart
|
||||
- web/src/tree/tree_benchmark.dart
|
||||
- web/src/page_load/page_load.dart
|
||||
- $dart2js:
|
||||
$include: web/src/**
|
||||
minify: false
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
<li>
|
||||
<a href="costs/index.html">Benchmarks measuring costs of things</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="page_load/page_load.html">Benchmark measuring time to bootstrap</a>
|
||||
</li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h2>Angular2 page load benchmark</h2>
|
||||
|
||||
<div>
|
||||
<app></app>
|
||||
</div>
|
||||
|
||||
$SCRIPTS$
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,11 @@
|
||||
import {Component} from 'angular2/core';
|
||||
import {bootstrap} from 'angular2/platform/browser';
|
||||
|
||||
@Component({selector: 'app', template: '<h1>Page Load Time</h1>'})
|
||||
class App {
|
||||
}
|
||||
|
||||
bootstrap(App).then(() => {
|
||||
(<any>window).loadTime = Date.now() - performance.timing.navigationStart;
|
||||
(<any>window).someConstant = 1234567890;
|
||||
});
|
||||
Reference in New Issue
Block a user