revert(format): Revert "chore(format): update to latest formatter"
This reverts commit 03627aa84d
.
This commit is contained in:
@ -49,9 +49,14 @@ var _REQUEST_COUNT = new OpaqueToken('Options.requestCount');
|
||||
var _CAPTURE_FRAMES = new OpaqueToken('Options.frameCapture');
|
||||
|
||||
var _DEFAULT_PROVIDERS = [
|
||||
bind(_DEFAULT_DESCRIPTION).toValue({}), provide(_SAMPLE_DESCRIPTION, {useValue: {}}),
|
||||
provide(_FORCE_GC, {useValue: false}), provide(_PREPARE, {useValue: false}),
|
||||
provide(_MICRO_METRICS, {useValue: {}}), provide(_NOW, {useValue: () => DateWrapper.now()}),
|
||||
provide(_RECEIVED_DATA, {useValue: false}), provide(_REQUEST_COUNT, {useValue: false}),
|
||||
bind(_DEFAULT_DESCRIPTION)
|
||||
.toValue({}),
|
||||
provide(_SAMPLE_DESCRIPTION, {useValue: {}}),
|
||||
provide(_FORCE_GC, {useValue: false}),
|
||||
provide(_PREPARE, {useValue: false}),
|
||||
provide(_MICRO_METRICS, {useValue: {}}),
|
||||
provide(_NOW, {useValue: () => DateWrapper.now()}),
|
||||
provide(_RECEIVED_DATA, {useValue: false}),
|
||||
provide(_REQUEST_COUNT, {useValue: false}),
|
||||
provide(_CAPTURE_FRAMES, {useValue: false})
|
||||
];
|
||||
|
@ -4,27 +4,25 @@ declare var unsafeWindow;
|
||||
exportFunction(function() {
|
||||
var curTime = unsafeWindow.performance.now();
|
||||
(<any>self).port.emit('startProfiler', curTime);
|
||||
}, unsafeWindow, {defineAs: 'startProfiler'});
|
||||
}, unsafeWindow, {defineAs: "startProfiler"});
|
||||
|
||||
exportFunction(function() {
|
||||
(<any>self).port.emit('stopProfiler');
|
||||
}, unsafeWindow, {defineAs: 'stopProfiler'});
|
||||
exportFunction(function() { (<any>self).port.emit('stopProfiler'); }, unsafeWindow,
|
||||
{defineAs: "stopProfiler"});
|
||||
|
||||
exportFunction(function(cb) {
|
||||
(<any>self).port.once('perfProfile', cb);
|
||||
(<any>self).port.emit('getProfile');
|
||||
}, unsafeWindow, {defineAs: 'getProfile'});
|
||||
}, unsafeWindow, {defineAs: "getProfile"});
|
||||
|
||||
exportFunction(function() {
|
||||
(<any>self).port.emit('forceGC');
|
||||
}, unsafeWindow, {defineAs: 'forceGC'});
|
||||
exportFunction(function() { (<any>self).port.emit('forceGC'); }, unsafeWindow,
|
||||
{defineAs: "forceGC"});
|
||||
|
||||
exportFunction(function(name) {
|
||||
var curTime = unsafeWindow.performance.now();
|
||||
(<any>self).port.emit('markStart', name, curTime);
|
||||
}, unsafeWindow, {defineAs: 'markStart'});
|
||||
}, unsafeWindow, {defineAs: "markStart"});
|
||||
|
||||
exportFunction(function(name) {
|
||||
var curTime = unsafeWindow.performance.now();
|
||||
(<any>self).port.emit('markEnd', name, curTime);
|
||||
}, unsafeWindow, {defineAs: 'markEnd'});
|
||||
}, unsafeWindow, {defineAs: "markEnd"});
|
||||
|
@ -53,13 +53,12 @@ mod.PageMod({
|
||||
include: ['*'],
|
||||
contentScriptFile: data.url('installed_script.js'),
|
||||
onAttach: worker => {
|
||||
worker.port.on(
|
||||
'startProfiler',
|
||||
(timeStarted) => profiler.start(
|
||||
/* = profiler memory */ 3000000, 0.1, ['leaf', 'js', 'stackwalk', 'gc'], timeStarted));
|
||||
worker.port.on('startProfiler',
|
||||
(timeStarted) => profiler.start(/* = profiler memory */ 3000000, 0.1,
|
||||
['leaf', 'js', 'stackwalk', 'gc'], timeStarted));
|
||||
worker.port.on('stopProfiler', () => profiler.stop());
|
||||
worker.port.on(
|
||||
'getProfile', () => worker.port.emit('perfProfile', profiler.getProfilePerfEvents()));
|
||||
worker.port.on('getProfile',
|
||||
() => worker.port.emit('perfProfile', profiler.getProfilePerfEvents()));
|
||||
worker.port.on('forceGC', forceGC);
|
||||
worker.port.on('markStart', (name, timeStarted) => profiler.addStartEvent(name, timeStarted));
|
||||
worker.port.on('markEnd', (name, timeEnded) => profiler.addEndEvent(name, timeEnded));
|
||||
|
@ -36,8 +36,9 @@ exports.getFirefoxProfileWithExtension = function() {
|
||||
var savedCwd = process.cwd();
|
||||
process.chdir(absPackageJsonDir);
|
||||
|
||||
return jpm(packageJson).then(xpiPath => {
|
||||
process.chdir(savedCwd);
|
||||
return exports.getFirefoxProfile(xpiPath);
|
||||
});
|
||||
return jpm(packageJson)
|
||||
.then(xpiPath => {
|
||||
process.chdir(savedCwd);
|
||||
return exports.getFirefoxProfile(xpiPath);
|
||||
});
|
||||
};
|
||||
|
@ -2,8 +2,8 @@ import {Date, DateWrapper} from 'angular2/src/facade/lang';
|
||||
import {Map} from 'angular2/src/facade/collection';
|
||||
|
||||
export class MeasureValues {
|
||||
constructor(
|
||||
public runIndex: number, public timeStamp: Date, public values: {[key: string]: any}) {}
|
||||
constructor(public runIndex: number, public timeStamp: Date,
|
||||
public values: {[key: string]: any}) {}
|
||||
|
||||
toJson() {
|
||||
return {
|
||||
|
@ -7,8 +7,9 @@ import {Metric} from '../metric';
|
||||
export class MultiMetric extends Metric {
|
||||
static createBindings(childTokens: any[]): Provider[] {
|
||||
return [
|
||||
bind(_CHILDREN).toFactory(
|
||||
(injector: Injector) => childTokens.map(token => injector.get(token)), [Injector]),
|
||||
bind(_CHILDREN)
|
||||
.toFactory((injector: Injector) => childTokens.map(token => injector.get(token)),
|
||||
[Injector]),
|
||||
bind(MultiMetric).toFactory(children => new MultiMetric(children), [_CHILDREN])
|
||||
];
|
||||
}
|
||||
@ -41,7 +42,7 @@ export class MultiMetric extends Metric {
|
||||
}
|
||||
}
|
||||
|
||||
function mergeStringMaps(maps: {[key: string]: string}[]): Object {
|
||||
function mergeStringMaps(maps: { [key: string]: string }[]): Object {
|
||||
var result = {};
|
||||
maps.forEach(
|
||||
map => { StringMapWrapper.forEach(map, (value, prop) => { result[prop] = value; }); });
|
||||
|
@ -1,5 +1,12 @@
|
||||
import {PromiseWrapper, TimerWrapper} from 'angular2/src/facade/async';
|
||||
import {isPresent, isBlank, StringWrapper, Math, RegExpWrapper, NumberWrapper} from 'angular2/src/facade/lang';
|
||||
import {
|
||||
isPresent,
|
||||
isBlank,
|
||||
StringWrapper,
|
||||
Math,
|
||||
RegExpWrapper,
|
||||
NumberWrapper
|
||||
} from 'angular2/src/facade/lang';
|
||||
import {BaseException, WrappedException} from 'angular2/src/facade/exceptions';
|
||||
import {ListWrapper, StringMapWrapper} from 'angular2/src/facade/collection';
|
||||
import {bind, provide, Provider, OpaqueToken} from 'angular2/src/core/di';
|
||||
@ -27,11 +34,10 @@ export class PerflogMetric extends Metric {
|
||||
* @param setTimeout
|
||||
* @param microMetrics Name and description of metrics provided via console.time / console.timeEnd
|
||||
**/
|
||||
constructor(
|
||||
private _driverExtension: WebDriverExtension, private _setTimeout: Function,
|
||||
private _microMetrics: {[key: string]: any}, private _forceGc: boolean,
|
||||
private _captureFrames: boolean, private _receivedData: boolean,
|
||||
private _requestCount: boolean) {
|
||||
constructor(private _driverExtension: WebDriverExtension, private _setTimeout: Function,
|
||||
private _microMetrics: {[key: string]: any}, private _forceGc: boolean,
|
||||
private _captureFrames: boolean, private _receivedData: boolean,
|
||||
private _requestCount: boolean) {
|
||||
super();
|
||||
|
||||
this._remainingEvents = [];
|
||||
@ -82,8 +88,8 @@ export class PerflogMetric extends Metric {
|
||||
res['frameTime.smooth'] = 'percentage of frames that hit 60fps';
|
||||
}
|
||||
}
|
||||
StringMapWrapper.forEach(
|
||||
this._microMetrics, (desc, name) => { StringMapWrapper.set(res, name, desc); });
|
||||
StringMapWrapper.forEach(this._microMetrics,
|
||||
(desc, name) => { StringMapWrapper.set(res, name, desc); });
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -142,13 +148,13 @@ export class PerflogMetric extends Metric {
|
||||
return result;
|
||||
}
|
||||
var completer = PromiseWrapper.completer();
|
||||
this._setTimeout(
|
||||
() => completer.resolve(this._readUntilEndMark(markName, loopCount + 1)), 100);
|
||||
this._setTimeout(() => completer.resolve(this._readUntilEndMark(markName, loopCount + 1)),
|
||||
100);
|
||||
return completer.promise;
|
||||
});
|
||||
}
|
||||
|
||||
_addEvents(events: {[key: string]: string}[]) {
|
||||
_addEvents(events: { [key: string]: string }[]) {
|
||||
var needSort = false;
|
||||
events.forEach(event => {
|
||||
if (StringWrapper.equals(event['ph'], 'X')) {
|
||||
@ -256,8 +262,8 @@ export class PerflogMetric extends Metric {
|
||||
'found start event for frame capture, but frame capture was not requested in benchpress')
|
||||
}
|
||||
frameCaptureStartEvent = event;
|
||||
} else if (
|
||||
StringWrapper.equals(ph, 'e') && StringWrapper.equals(name, _MARK_NAME_FRAME_CAPUTRE)) {
|
||||
} else if (StringWrapper.equals(ph, 'e') &&
|
||||
StringWrapper.equals(name, _MARK_NAME_FRAME_CAPUTRE)) {
|
||||
if (isBlank(frameCaptureStartEvent)) {
|
||||
throw new BaseException('missing start event for frame capture');
|
||||
}
|
||||
@ -269,9 +275,8 @@ export class PerflogMetric extends Metric {
|
||||
StringWrapper.equals(name, 'frame')) {
|
||||
frameTimestamps.push(event['ts']);
|
||||
if (frameTimestamps.length >= 2) {
|
||||
frameTimes.push(
|
||||
frameTimestamps[frameTimestamps.length - 1] -
|
||||
frameTimestamps[frameTimestamps.length - 2]);
|
||||
frameTimes.push(frameTimestamps[frameTimestamps.length - 1] -
|
||||
frameTimestamps[frameTimestamps.length - 2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -283,9 +288,8 @@ export class PerflogMetric extends Metric {
|
||||
} else {
|
||||
intervalStartCount[name]++;
|
||||
}
|
||||
} else if (
|
||||
(StringWrapper.equals(ph, 'E') || StringWrapper.equals(ph, 'e')) &&
|
||||
isPresent(intervalStarts[name])) {
|
||||
} else if ((StringWrapper.equals(ph, 'E') || StringWrapper.equals(ph, 'e')) &&
|
||||
isPresent(intervalStarts[name])) {
|
||||
intervalStartCount[name]--;
|
||||
if (intervalStartCount[name] === 0) {
|
||||
var startEvent = intervalStarts[name];
|
||||
@ -363,13 +367,16 @@ var _PROVIDERS = [
|
||||
bind(PerflogMetric)
|
||||
.toFactory(
|
||||
(driverExtension, setTimeout, microMetrics, forceGc, captureFrames, receivedData,
|
||||
requestCount) =>
|
||||
new PerflogMetric(
|
||||
driverExtension, setTimeout, microMetrics, forceGc, captureFrames, receivedData,
|
||||
requestCount),
|
||||
requestCount) => new PerflogMetric(driverExtension, setTimeout, microMetrics, forceGc,
|
||||
captureFrames, receivedData, requestCount),
|
||||
[
|
||||
WebDriverExtension, _SET_TIMEOUT, Options.MICRO_METRICS, Options.FORCE_GC,
|
||||
Options.CAPTURE_FRAMES, Options.RECEIVED_DATA, Options.REQUEST_COUNT
|
||||
WebDriverExtension,
|
||||
_SET_TIMEOUT,
|
||||
Options.MICRO_METRICS,
|
||||
Options.FORCE_GC,
|
||||
Options.CAPTURE_FRAMES,
|
||||
Options.RECEIVED_DATA,
|
||||
Options.REQUEST_COUNT
|
||||
]),
|
||||
provide(_SET_TIMEOUT, {useValue: (fn, millis) => TimerWrapper.setTimeout(fn, millis)})
|
||||
];
|
||||
|
@ -75,13 +75,12 @@ export class ConsoleReporter extends Reporter {
|
||||
var samples = validSamples.map(measureValues => measureValues.values[metricName]);
|
||||
var mean = Statistic.calculateMean(samples);
|
||||
var cv = Statistic.calculateCoefficientOfVariation(samples, mean);
|
||||
var formattedMean = ConsoleReporter
|
||||
._formatNum(mean)
|
||||
// Note: Don't use the unicode character for +- as it might cause
|
||||
// hickups for consoles...
|
||||
return NumberWrapper.isNaN(cv) ?
|
||||
formattedMean :
|
||||
`${formattedMean}+-${Math.floor(cv)}%`;
|
||||
var formattedMean = ConsoleReporter._formatNum(mean)
|
||||
// Note: Don't use the unicode character for +- as it might cause
|
||||
// hickups for consoles...
|
||||
return NumberWrapper.isNaN(cv) ?
|
||||
formattedMean :
|
||||
`${formattedMean}+-${Math.floor(cv)}%`;
|
||||
}));
|
||||
return PromiseWrapper.resolve(null);
|
||||
}
|
||||
@ -96,9 +95,9 @@ var _PRINT = new OpaqueToken('ConsoleReporter.print');
|
||||
var _COLUMN_WIDTH = new OpaqueToken('ConsoleReporter.columnWidth');
|
||||
var _PROVIDERS = [
|
||||
bind(ConsoleReporter)
|
||||
.toFactory(
|
||||
(columnWidth, sampleDescription, print) =>
|
||||
new ConsoleReporter(columnWidth, sampleDescription, print),
|
||||
[_COLUMN_WIDTH, SampleDescription, _PRINT]),
|
||||
provide(_COLUMN_WIDTH, {useValue: 18}), provide(_PRINT, {useValue: print})
|
||||
.toFactory((columnWidth, sampleDescription, print) =>
|
||||
new ConsoleReporter(columnWidth, sampleDescription, print),
|
||||
[_COLUMN_WIDTH, SampleDescription, _PRINT]),
|
||||
provide(_COLUMN_WIDTH, {useValue: 18}),
|
||||
provide(_PRINT, {useValue: print})
|
||||
];
|
||||
|
@ -49,9 +49,8 @@ export class JsonFileReporter extends Reporter {
|
||||
var _PATH = new OpaqueToken('JsonFileReporter.path');
|
||||
var _PROVIDERS = [
|
||||
bind(JsonFileReporter)
|
||||
.toFactory(
|
||||
(sampleDescription, path, writeFile, now) =>
|
||||
new JsonFileReporter(sampleDescription, path, writeFile, now),
|
||||
[SampleDescription, _PATH, Options.WRITE_FILE, Options.NOW]),
|
||||
.toFactory((sampleDescription, path, writeFile, now) =>
|
||||
new JsonFileReporter(sampleDescription, path, writeFile, now),
|
||||
[SampleDescription, _PATH, Options.WRITE_FILE, Options.NOW]),
|
||||
provide(_PATH, {useValue: '.'})
|
||||
];
|
||||
|
@ -7,8 +7,9 @@ import {Reporter} from '../reporter';
|
||||
export class MultiReporter extends Reporter {
|
||||
static createBindings(childTokens: any[]): Provider[] {
|
||||
return [
|
||||
bind(_CHILDREN).toFactory(
|
||||
(injector: Injector) => childTokens.map(token => injector.get(token)), [Injector]),
|
||||
bind(_CHILDREN)
|
||||
.toFactory((injector: Injector) => childTokens.map(token => injector.get(token)),
|
||||
[Injector]),
|
||||
bind(MultiReporter).toFactory(children => new MultiReporter(children), [_CHILDREN])
|
||||
];
|
||||
}
|
||||
|
@ -37,7 +37,9 @@ export class Runner {
|
||||
{id: string, execute?: any, prepare?: any, microMetrics?: any, bindings?: any}):
|
||||
Promise<SampleState> {
|
||||
var sampleBindings = [
|
||||
_DEFAULT_PROVIDERS, this._defaultBindings, bind(Options.SAMPLE_ID).toValue(id),
|
||||
_DEFAULT_PROVIDERS,
|
||||
this._defaultBindings,
|
||||
bind(Options.SAMPLE_ID).toValue(id),
|
||||
bind(Options.EXECUTE).toValue(execute)
|
||||
];
|
||||
if (isPresent(prepare)) {
|
||||
@ -65,7 +67,8 @@ export class Runner {
|
||||
// TODO vsavkin consider changing it when toAsyncFactory is added back or when child
|
||||
// injectors are handled better.
|
||||
var injector = Injector.resolveAndCreate([
|
||||
sampleBindings, bind(Options.CAPABILITIES).toValue(capabilities),
|
||||
sampleBindings,
|
||||
bind(Options.CAPABILITIES).toValue(capabilities),
|
||||
bind(Options.USER_AGENT).toValue(userAgent),
|
||||
provide(WebDriverAdapter, {useValue: adapter})
|
||||
]);
|
||||
|
@ -12,9 +12,8 @@ export class SampleDescription {
|
||||
static get BINDINGS(): Provider[] { return _PROVIDERS; }
|
||||
description: {[key: string]: any};
|
||||
|
||||
constructor(
|
||||
public id: string, descriptions: Array<{[key: string]: any}>,
|
||||
public metrics: {[key: string]: any}) {
|
||||
constructor(public id: string, descriptions: Array<{[key: string]: any}>,
|
||||
public metrics: {[key: string]: any}) {
|
||||
this.description = {};
|
||||
descriptions.forEach(description => {
|
||||
StringMapWrapper.forEach(description, (value, prop) => this.description[prop] = value);
|
||||
@ -24,17 +23,24 @@ export class SampleDescription {
|
||||
toJson() { return {'id': this.id, 'description': this.description, 'metrics': this.metrics}; }
|
||||
}
|
||||
|
||||
var _PROVIDERS = [bind(SampleDescription)
|
||||
.toFactory(
|
||||
(metric, id, forceGc, userAgent, validator, defaultDesc, userDesc) =>
|
||||
new SampleDescription(
|
||||
id,
|
||||
[
|
||||
{'forceGc': forceGc, 'userAgent': userAgent},
|
||||
validator.describe(), defaultDesc, userDesc
|
||||
],
|
||||
metric.describe()),
|
||||
[
|
||||
Metric, Options.SAMPLE_ID, Options.FORCE_GC, Options.USER_AGENT,
|
||||
Validator, Options.DEFAULT_DESCRIPTION, Options.SAMPLE_DESCRIPTION
|
||||
])];
|
||||
var _PROVIDERS = [
|
||||
bind(SampleDescription)
|
||||
.toFactory((metric, id, forceGc, userAgent, validator, defaultDesc, userDesc) =>
|
||||
new SampleDescription(id,
|
||||
[
|
||||
{'forceGc': forceGc, 'userAgent': userAgent},
|
||||
validator.describe(),
|
||||
defaultDesc,
|
||||
userDesc
|
||||
],
|
||||
metric.describe()),
|
||||
[
|
||||
Metric,
|
||||
Options.SAMPLE_ID,
|
||||
Options.FORCE_GC,
|
||||
Options.USER_AGENT,
|
||||
Validator,
|
||||
Options.DEFAULT_DESCRIPTION,
|
||||
Options.SAMPLE_DESCRIPTION
|
||||
])
|
||||
];
|
||||
|
@ -94,19 +94,27 @@ export class SampleState {
|
||||
constructor(public completeSample: any[], public validSample: any[]) {}
|
||||
}
|
||||
|
||||
var _PROVIDERS = [bind(Sampler).toFactory(
|
||||
(driver, metric, reporter, validator, prepare, execute, now) => new Sampler({
|
||||
driver: driver,
|
||||
reporter: reporter,
|
||||
validator: validator,
|
||||
metric: metric,
|
||||
// TODO(tbosch): DI right now does not support null/undefined objects
|
||||
// Mostly because the cache would have to be initialized with a
|
||||
// special null object, which is expensive.
|
||||
prepare: prepare !== false ? prepare : null,
|
||||
execute: execute,
|
||||
now: now
|
||||
}),
|
||||
[
|
||||
WebDriverAdapter, Metric, Reporter, Validator, Options.PREPARE, Options.EXECUTE, Options.NOW
|
||||
])];
|
||||
var _PROVIDERS = [
|
||||
bind(Sampler)
|
||||
.toFactory((driver, metric, reporter, validator, prepare, execute, now) => new Sampler({
|
||||
driver: driver,
|
||||
reporter: reporter,
|
||||
validator: validator,
|
||||
metric: metric,
|
||||
// TODO(tbosch): DI right now does not support null/undefined objects
|
||||
// Mostly because the cache would have to be initialized with a
|
||||
// special null object, which is expensive.
|
||||
prepare: prepare !== false ? prepare : null,
|
||||
execute: execute,
|
||||
now: now
|
||||
}),
|
||||
[
|
||||
WebDriverAdapter,
|
||||
Metric,
|
||||
Reporter,
|
||||
Validator,
|
||||
Options.PREPARE,
|
||||
Options.EXECUTE,
|
||||
Options.NOW
|
||||
])
|
||||
];
|
||||
|
@ -21,8 +21,8 @@ export class Statistic {
|
||||
return deviation;
|
||||
}
|
||||
|
||||
static calculateRegressionSlope(
|
||||
xValues: number[], xMean: number, yValues: number[], yMean: number) {
|
||||
static calculateRegressionSlope(xValues: number[], xMean: number, yValues: number[],
|
||||
yMean: number) {
|
||||
// See http://en.wikipedia.org/wiki/Simple_linear_regression
|
||||
var dividendSum = 0;
|
||||
var divisorSum = 0;
|
||||
|
@ -32,8 +32,8 @@ export class RegressionSlopeValidator extends Validator {
|
||||
|
||||
validate(completeSample: MeasureValues[]): MeasureValues[] {
|
||||
if (completeSample.length >= this._sampleSize) {
|
||||
var latestSample = ListWrapper.slice(
|
||||
completeSample, completeSample.length - this._sampleSize, completeSample.length);
|
||||
var latestSample = ListWrapper.slice(completeSample, completeSample.length - this._sampleSize,
|
||||
completeSample.length);
|
||||
var xValues = [];
|
||||
var yValues = [];
|
||||
for (var i = 0; i < latestSample.length; i++) {
|
||||
@ -55,8 +55,8 @@ var _SAMPLE_SIZE = new OpaqueToken('RegressionSlopeValidator.sampleSize');
|
||||
var _METRIC = new OpaqueToken('RegressionSlopeValidator.metric');
|
||||
var _PROVIDERS = [
|
||||
bind(RegressionSlopeValidator)
|
||||
.toFactory(
|
||||
(sampleSize, metric) => new RegressionSlopeValidator(sampleSize, metric),
|
||||
[_SAMPLE_SIZE, _METRIC]),
|
||||
provide(_SAMPLE_SIZE, {useValue: 10}), provide(_METRIC, {useValue: 'scriptTime'})
|
||||
.toFactory((sampleSize, metric) => new RegressionSlopeValidator(sampleSize, metric),
|
||||
[_SAMPLE_SIZE, _METRIC]),
|
||||
provide(_SAMPLE_SIZE, {useValue: 10}),
|
||||
provide(_METRIC, {useValue: 'scriptTime'})
|
||||
];
|
||||
|
@ -24,8 +24,8 @@ export class SizeValidator extends Validator {
|
||||
|
||||
validate(completeSample: MeasureValues[]): MeasureValues[] {
|
||||
if (completeSample.length >= this._sampleSize) {
|
||||
return ListWrapper.slice(
|
||||
completeSample, completeSample.length - this._sampleSize, completeSample.length);
|
||||
return ListWrapper.slice(completeSample, completeSample.length - this._sampleSize,
|
||||
completeSample.length);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -34,6 +34,7 @@ export class SizeValidator extends Validator {
|
||||
|
||||
var _SAMPLE_SIZE = new OpaqueToken('SizeValidator.sampleSize');
|
||||
var _PROVIDERS = [
|
||||
bind(SizeValidator).toFactory((size) => new SizeValidator(size), [_SAMPLE_SIZE]),
|
||||
bind(SizeValidator)
|
||||
.toFactory((size) => new SizeValidator(size), [_SAMPLE_SIZE]),
|
||||
provide(_SAMPLE_SIZE, {useValue: 10})
|
||||
];
|
||||
|
@ -13,8 +13,9 @@ import {Options} from './common_options';
|
||||
export abstract class WebDriverExtension {
|
||||
static bindTo(childTokens: any[]): Provider[] {
|
||||
var res = [
|
||||
bind(_CHILDREN).toFactory(
|
||||
(injector: Injector) => childTokens.map(token => injector.get(token)), [Injector]),
|
||||
bind(_CHILDREN)
|
||||
.toFactory((injector: Injector) => childTokens.map(token => injector.get(token)),
|
||||
[Injector]),
|
||||
bind(WebDriverExtension)
|
||||
.toFactory(
|
||||
(children: WebDriverExtension[], capabilities) => {
|
||||
|
@ -1,6 +1,13 @@
|
||||
import {bind, provide, Provider} from 'angular2/src/core/di';
|
||||
import {ListWrapper, StringMapWrapper} from 'angular2/src/facade/collection';
|
||||
import {Json, isPresent, isBlank, RegExpWrapper, StringWrapper, NumberWrapper} from 'angular2/src/facade/lang';
|
||||
import {
|
||||
Json,
|
||||
isPresent,
|
||||
isBlank,
|
||||
RegExpWrapper,
|
||||
StringWrapper,
|
||||
NumberWrapper
|
||||
} from 'angular2/src/facade/lang';
|
||||
import {BaseException, WrappedException} from 'angular2/src/facade/exceptions';
|
||||
|
||||
import {WebDriverExtension, PerfLogFeatures} from '../web_driver_extension';
|
||||
@ -76,9 +83,8 @@ export class ChromeDriverExtension extends WebDriverExtension {
|
||||
});
|
||||
}
|
||||
|
||||
private _convertPerfRecordsToEvents(
|
||||
chromeEvents: Array<{[key: string]: any}>,
|
||||
normalizedEvents: Array<{[key: string]: any}> = null) {
|
||||
private _convertPerfRecordsToEvents(chromeEvents: Array<{[key: string]: any}>,
|
||||
normalizedEvents: Array<{[key: string]: any}> = null) {
|
||||
if (isBlank(normalizedEvents)) {
|
||||
normalizedEvents = [];
|
||||
}
|
||||
@ -88,9 +94,8 @@ export class ChromeDriverExtension extends WebDriverExtension {
|
||||
var name = event['name'];
|
||||
if (this._isEvent(categories, name, ['blink.console'])) {
|
||||
normalizedEvents.push(normalizeEvent(event, {'name': name}));
|
||||
} else if (this._isEvent(
|
||||
categories, name, ['benchmark'],
|
||||
'BenchmarkInstrumentation::ImplThreadRenderingStats')) {
|
||||
} else if (this._isEvent(categories, name, ['benchmark'],
|
||||
'BenchmarkInstrumentation::ImplThreadRenderingStats')) {
|
||||
// TODO(goderbauer): Instead of BenchmarkInstrumentation::ImplThreadRenderingStats the
|
||||
// following events should be used (if available) for more accurate measurments:
|
||||
// 1st choice: vsync_before - ground truth on Android
|
||||
@ -105,10 +110,10 @@ export class ChromeDriverExtension extends WebDriverExtension {
|
||||
if (frameCount == 1) {
|
||||
normalizedEvents.push(normalizeEvent(event, {'name': 'frame'}));
|
||||
}
|
||||
} else if (
|
||||
this._isEvent(categories, name, ['disabled-by-default-devtools.timeline'], 'Rasterize') ||
|
||||
this._isEvent(
|
||||
categories, name, ['disabled-by-default-devtools.timeline'], 'CompositeLayers')) {
|
||||
} else if (this._isEvent(categories, name, ['disabled-by-default-devtools.timeline'],
|
||||
'Rasterize') ||
|
||||
this._isEvent(categories, name, ['disabled-by-default-devtools.timeline'],
|
||||
'CompositeLayers')) {
|
||||
normalizedEvents.push(normalizeEvent(event, {'name': 'render'}));
|
||||
} else if (this._majorChromeVersion < 45) {
|
||||
var normalizedEvent = this._processAsPreChrome45Event(event, categories, majorGCPids);
|
||||
@ -126,21 +131,22 @@ export class ChromeDriverExtension extends WebDriverExtension {
|
||||
var args = event['args'];
|
||||
var pid = event['pid'];
|
||||
var ph = event['ph'];
|
||||
if (this._isEvent(
|
||||
categories, name, ['disabled-by-default-devtools.timeline'], 'FunctionCall') &&
|
||||
if (this._isEvent(categories, name, ['disabled-by-default-devtools.timeline'],
|
||||
'FunctionCall') &&
|
||||
(isBlank(args) || isBlank(args['data']) ||
|
||||
!StringWrapper.equals(args['data']['scriptName'], 'InjectedScript'))) {
|
||||
return normalizeEvent(event, {'name': 'script'});
|
||||
} else if (
|
||||
this._isEvent(
|
||||
categories, name, ['disabled-by-default-devtools.timeline'], 'RecalculateStyles') ||
|
||||
this._isEvent(categories, name, ['disabled-by-default-devtools.timeline'], 'Layout') ||
|
||||
this._isEvent(
|
||||
categories, name, ['disabled-by-default-devtools.timeline'], 'UpdateLayerTree') ||
|
||||
this._isEvent(categories, name, ['disabled-by-default-devtools.timeline'], 'Paint')) {
|
||||
} else if (this._isEvent(categories, name, ['disabled-by-default-devtools.timeline'],
|
||||
'RecalculateStyles') ||
|
||||
this._isEvent(categories, name, ['disabled-by-default-devtools.timeline'],
|
||||
'Layout') ||
|
||||
this._isEvent(categories, name, ['disabled-by-default-devtools.timeline'],
|
||||
'UpdateLayerTree') ||
|
||||
this._isEvent(categories, name, ['disabled-by-default-devtools.timeline'],
|
||||
'Paint')) {
|
||||
return normalizeEvent(event, {'name': 'render'});
|
||||
} else if (this._isEvent(
|
||||
categories, name, ['disabled-by-default-devtools.timeline'], 'GCEvent')) {
|
||||
} else if (this._isEvent(categories, name, ['disabled-by-default-devtools.timeline'],
|
||||
'GCEvent')) {
|
||||
var normArgs = {
|
||||
'usedHeapSize': isPresent(args['usedHeapSizeAfter']) ? args['usedHeapSizeAfter'] :
|
||||
args['usedHeapSizeBefore']
|
||||
@ -150,8 +156,8 @@ export class ChromeDriverExtension extends WebDriverExtension {
|
||||
}
|
||||
majorGCPids[pid] = false;
|
||||
return normalizeEvent(event, {'name': 'gc', 'args': normArgs});
|
||||
} else if (
|
||||
this._isEvent(categories, name, ['v8'], 'majorGC') && StringWrapper.equals(ph, 'B')) {
|
||||
} else if (this._isEvent(categories, name, ['v8'], 'majorGC') &&
|
||||
StringWrapper.equals(ph, 'B')) {
|
||||
majorGCPids[pid] = true;
|
||||
}
|
||||
return null; // nothing useful in this event
|
||||
@ -174,19 +180,17 @@ export class ChromeDriverExtension extends WebDriverExtension {
|
||||
args['usedHeapSizeBefore']
|
||||
};
|
||||
return normalizeEvent(event, {'name': 'gc', 'args': normArgs});
|
||||
} else if (
|
||||
this._isEvent(categories, name, ['devtools.timeline', 'v8'], 'FunctionCall') &&
|
||||
(isBlank(args) || isBlank(args['data']) ||
|
||||
(!StringWrapper.equals(args['data']['scriptName'], 'InjectedScript') &&
|
||||
!StringWrapper.equals(args['data']['scriptName'], '')))) {
|
||||
} else if (this._isEvent(categories, name, ['devtools.timeline', 'v8'], 'FunctionCall') &&
|
||||
(isBlank(args) || isBlank(args['data']) ||
|
||||
(!StringWrapper.equals(args['data']['scriptName'], 'InjectedScript') &&
|
||||
!StringWrapper.equals(args['data']['scriptName'], '')))) {
|
||||
return normalizeEvent(event, {'name': 'script'});
|
||||
} else if (this._isEvent(
|
||||
categories, name, ['devtools.timeline', 'blink'], 'UpdateLayoutTree')) {
|
||||
} else if (this._isEvent(categories, name, ['devtools.timeline', 'blink'],
|
||||
'UpdateLayoutTree')) {
|
||||
return normalizeEvent(event, {'name': 'render'});
|
||||
} else if (
|
||||
this._isEvent(categories, name, ['devtools.timeline'], 'UpdateLayerTree') ||
|
||||
this._isEvent(categories, name, ['devtools.timeline'], 'Layout') ||
|
||||
this._isEvent(categories, name, ['devtools.timeline'], 'Paint')) {
|
||||
} else if (this._isEvent(categories, name, ['devtools.timeline'], 'UpdateLayerTree') ||
|
||||
this._isEvent(categories, name, ['devtools.timeline'], 'Layout') ||
|
||||
this._isEvent(categories, name, ['devtools.timeline'], 'Paint')) {
|
||||
return normalizeEvent(event, {'name': 'render'});
|
||||
} else if (this._isEvent(categories, name, ['devtools.timeline'], 'ResourceReceivedData')) {
|
||||
let normArgs = {'encodedDataLength': args['data']['encodedDataLength']};
|
||||
@ -203,9 +207,8 @@ export class ChromeDriverExtension extends WebDriverExtension {
|
||||
|
||||
private _parseCategories(categories: string): string[] { return categories.split(','); }
|
||||
|
||||
private _isEvent(
|
||||
eventCategories: string[], eventName: string, expectedCategories: string[],
|
||||
expectedName: string = null): boolean {
|
||||
private _isEvent(eventCategories: string[], eventName: string, expectedCategories: string[],
|
||||
expectedName: string = null): boolean {
|
||||
var hasCategories = expectedCategories.reduce(
|
||||
(value, cat) => { return value && ListWrapper.contains(eventCategories, cat); }, true);
|
||||
return isBlank(expectedName) ? hasCategories :
|
||||
@ -218,12 +221,12 @@ export class ChromeDriverExtension extends WebDriverExtension {
|
||||
|
||||
supports(capabilities: {[key: string]: any}): boolean {
|
||||
return this._majorChromeVersion != -1 &&
|
||||
StringWrapper.equals(capabilities['browserName'].toLowerCase(), 'chrome');
|
||||
StringWrapper.equals(capabilities['browserName'].toLowerCase(), 'chrome');
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeEvent(
|
||||
chromeEvent: {[key: string]: any}, data: {[key: string]: any}): {[key: string]: any} {
|
||||
function normalizeEvent(chromeEvent: {[key: string]: any},
|
||||
data: {[key: string]: any}): {[key: string]: any} {
|
||||
var ph = chromeEvent['ph'];
|
||||
if (StringWrapper.equals(ph, 'S')) {
|
||||
ph = 'b';
|
||||
@ -243,7 +246,8 @@ function normalizeEvent(
|
||||
return result;
|
||||
}
|
||||
|
||||
var _PROVIDERS = [bind(ChromeDriverExtension)
|
||||
.toFactory(
|
||||
(driver, userAgent) => new ChromeDriverExtension(driver, userAgent),
|
||||
[WebDriverAdapter, Options.USER_AGENT])];
|
||||
var _PROVIDERS = [
|
||||
bind(ChromeDriverExtension)
|
||||
.toFactory((driver, userAgent) => new ChromeDriverExtension(driver, userAgent),
|
||||
[WebDriverAdapter, Options.USER_AGENT])
|
||||
];
|
||||
|
@ -42,7 +42,7 @@ export class FirefoxDriverExtension extends WebDriverExtension {
|
||||
}
|
||||
}
|
||||
|
||||
var _PROVIDERS =
|
||||
[bind(FirefoxDriverExtension).toFactory((driver) => new FirefoxDriverExtension(driver), [
|
||||
WebDriverAdapter
|
||||
])];
|
||||
var _PROVIDERS = [
|
||||
bind(FirefoxDriverExtension)
|
||||
.toFactory((driver) => new FirefoxDriverExtension(driver), [WebDriverAdapter])
|
||||
];
|
||||
|
@ -62,11 +62,11 @@ export class IOsDriverExtension extends WebDriverExtension {
|
||||
events.push(createMarkStartEvent(data['message'], startTime));
|
||||
} else if (StringWrapper.equals(type, 'TimeEnd')) {
|
||||
events.push(createMarkEndEvent(data['message'], startTime));
|
||||
} else if (
|
||||
StringWrapper.equals(type, 'RecalculateStyles') || StringWrapper.equals(type, 'Layout') ||
|
||||
StringWrapper.equals(type, 'UpdateLayerTree') || StringWrapper.equals(type, 'Paint') ||
|
||||
StringWrapper.equals(type, 'Rasterize') ||
|
||||
StringWrapper.equals(type, 'CompositeLayers')) {
|
||||
} else if (StringWrapper.equals(type, 'RecalculateStyles') ||
|
||||
StringWrapper.equals(type, 'Layout') ||
|
||||
StringWrapper.equals(type, 'UpdateLayerTree') ||
|
||||
StringWrapper.equals(type, 'Paint') || StringWrapper.equals(type, 'Rasterize') ||
|
||||
StringWrapper.equals(type, 'CompositeLayers')) {
|
||||
events.push(createStartEvent('render', startTime));
|
||||
endEvent = createEndEvent('render', endTime);
|
||||
}
|
||||
@ -121,5 +121,6 @@ function createMarkEndEvent(name, time) {
|
||||
}
|
||||
|
||||
var _PROVIDERS = [
|
||||
bind(IOsDriverExtension).toFactory((driver) => new IOsDriverExtension(driver), [WebDriverAdapter])
|
||||
bind(IOsDriverExtension)
|
||||
.toFactory((driver) => new IOsDriverExtension(driver), [WebDriverAdapter])
|
||||
];
|
||||
|
@ -57,5 +57,6 @@ function convertToLocalProcess(data): Object {
|
||||
}
|
||||
|
||||
var _PROTRACTOR_BINDINGS = [
|
||||
bind(WebDriverAdapter).toFactory(() => new SeleniumWebDriverAdapter((<any>global).browser), [])
|
||||
bind(WebDriverAdapter)
|
||||
.toFactory(() => new SeleniumWebDriverAdapter((<any>global).browser), [])
|
||||
];
|
||||
|
@ -25,48 +25,56 @@ export function main() {
|
||||
|
||||
it('should convert single non-instantaneous event', function() {
|
||||
var profileData = {
|
||||
threads: [{
|
||||
samples: [
|
||||
{time: 1, frames: [{location: 'FirefoxDriver.prototype.executeScript'}]},
|
||||
{time: 2, frames: [{location: 'FirefoxDriver.prototype.executeScript'}]},
|
||||
{time: 100, frames: [{location: 'FirefoxDriver.prototype.executeScript'}]}
|
||||
]
|
||||
}]
|
||||
threads: [
|
||||
{
|
||||
samples: [
|
||||
{time: 1, frames: [{location: 'FirefoxDriver.prototype.executeScript'}]},
|
||||
{time: 2, frames: [{location: 'FirefoxDriver.prototype.executeScript'}]},
|
||||
{time: 100, frames: [{location: 'FirefoxDriver.prototype.executeScript'}]}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
var perfEvents = convertPerfProfileToEvents(profileData);
|
||||
assertEventsEqual(
|
||||
perfEvents, [{ph: 'B', ts: 1, name: 'script'}, {ph: 'E', ts: 100, name: 'script'}]);
|
||||
assertEventsEqual(perfEvents,
|
||||
[{ph: 'B', ts: 1, name: 'script'}, {ph: 'E', ts: 100, name: 'script'}]);
|
||||
});
|
||||
|
||||
it('should convert multiple instantaneous events', function() {
|
||||
var profileData = {
|
||||
threads: [{
|
||||
samples: [
|
||||
{time: 1, frames: [{location: 'FirefoxDriver.prototype.executeScript'}]},
|
||||
{time: 2, frames: [{location: 'PresShell::Paint'}]}
|
||||
]
|
||||
}]
|
||||
threads: [
|
||||
{
|
||||
samples: [
|
||||
{time: 1, frames: [{location: 'FirefoxDriver.prototype.executeScript'}]},
|
||||
{time: 2, frames: [{location: 'PresShell::Paint'}]}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
var perfEvents = convertPerfProfileToEvents(profileData);
|
||||
assertEventsEqual(
|
||||
perfEvents, [{ph: 'X', ts: 1, name: 'script'}, {ph: 'X', ts: 2, name: 'render'}]);
|
||||
assertEventsEqual(perfEvents,
|
||||
[{ph: 'X', ts: 1, name: 'script'}, {ph: 'X', ts: 2, name: 'render'}]);
|
||||
});
|
||||
|
||||
it('should convert multiple mixed events', function() {
|
||||
var profileData = {
|
||||
threads: [{
|
||||
samples: [
|
||||
{time: 1, frames: [{location: 'FirefoxDriver.prototype.executeScript'}]},
|
||||
{time: 2, frames: [{location: 'PresShell::Paint'}]},
|
||||
{time: 5, frames: [{location: 'FirefoxDriver.prototype.executeScript'}]},
|
||||
{time: 10, frames: [{location: 'FirefoxDriver.prototype.executeScript'}]}
|
||||
]
|
||||
}]
|
||||
threads: [
|
||||
{
|
||||
samples: [
|
||||
{time: 1, frames: [{location: 'FirefoxDriver.prototype.executeScript'}]},
|
||||
{time: 2, frames: [{location: 'PresShell::Paint'}]},
|
||||
{time: 5, frames: [{location: 'FirefoxDriver.prototype.executeScript'}]},
|
||||
{time: 10, frames: [{location: 'FirefoxDriver.prototype.executeScript'}]}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
var perfEvents = convertPerfProfileToEvents(profileData);
|
||||
assertEventsEqual(perfEvents, [
|
||||
{ph: 'X', ts: 1, name: 'script'}, {ph: 'X', ts: 2, name: 'render'},
|
||||
{ph: 'B', ts: 5, name: 'script'}, {ph: 'E', ts: 10, name: 'script'}
|
||||
{ph: 'X', ts: 1, name: 'script'},
|
||||
{ph: 'X', ts: 2, name: 'render'},
|
||||
{ph: 'B', ts: 5, name: 'script'},
|
||||
{ph: 'E', ts: 10, name: 'script'}
|
||||
]);
|
||||
});
|
||||
|
||||
@ -78,12 +86,14 @@ export function main() {
|
||||
|
||||
it('should skip unknown events', function() {
|
||||
var profileData = {
|
||||
threads: [{
|
||||
samples: [
|
||||
{time: 1, frames: [{location: 'FirefoxDriver.prototype.executeScript'}]},
|
||||
{time: 2, frames: [{location: 'foo'}]}
|
||||
]
|
||||
}]
|
||||
threads: [
|
||||
{
|
||||
samples: [
|
||||
{time: 1, frames: [{location: 'FirefoxDriver.prototype.executeScript'}]},
|
||||
{time: 2, frames: [{location: 'foo'}]}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
var perfEvents = convertPerfProfileToEvents(profileData);
|
||||
assertEventsEqual(perfEvents, [{ph: 'X', ts: 1, name: 'script'}]);
|
||||
|
@ -21,14 +21,12 @@ describe('deep tree baseline', function() {
|
||||
* Benchpress will log the collected metrics after each sample is collected, and will stop
|
||||
* sampling as soon as the calculated regression slope for last 20 samples is stable.
|
||||
*/
|
||||
runner
|
||||
.sample({
|
||||
id: 'baseline',
|
||||
execute: function() {
|
||||
$('button').click();
|
||||
},
|
||||
bindings: [benchpress.bind(benchpress.Options.SAMPLE_DESCRIPTION).toValue({depth: 9})]
|
||||
})
|
||||
runner.sample({
|
||||
id: 'baseline',
|
||||
execute: function() { $('button')
|
||||
.click(); },
|
||||
bindings: [benchpress.bind(benchpress.Options.SAMPLE_DESCRIPTION).toValue({depth: 9})]
|
||||
})
|
||||
.then(done, done.fail);
|
||||
});
|
||||
});
|
||||
|
@ -21,9 +21,8 @@ describe('firefox extension', function() {
|
||||
|
||||
browser.driver.get(TEST_URL);
|
||||
|
||||
browser.executeScript('window.startProfiler()').then(function() {
|
||||
console.log('started measuring perf');
|
||||
});
|
||||
browser.executeScript('window.startProfiler()')
|
||||
.then(function() { console.log('started measuring perf'); });
|
||||
|
||||
browser.executeAsyncScript('setTimeout(arguments[0], 1000);');
|
||||
browser.executeScript('window.forceGC()');
|
||||
|
@ -1,4 +1,15 @@
|
||||
import {afterEach, AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from 'angular2/testing_internal';
|
||||
import {
|
||||
afterEach,
|
||||
AsyncTestCompleter,
|
||||
beforeEach,
|
||||
ddescribe,
|
||||
describe,
|
||||
expect,
|
||||
iit,
|
||||
inject,
|
||||
it,
|
||||
xit,
|
||||
} from 'angular2/testing_internal';
|
||||
|
||||
import {ListWrapper} from 'angular2/src/facade/collection';
|
||||
import {PromiseWrapper} from 'angular2/src/facade/async';
|
||||
@ -7,38 +18,42 @@ import {Metric, MultiMetric, bind, provide, Injector} from 'benchpress/common';
|
||||
|
||||
export function main() {
|
||||
function createMetric(ids: any[]) {
|
||||
var m = Injector
|
||||
.resolveAndCreate([
|
||||
ids.map(id => provide(id, {useValue: new MockMetric(id)})),
|
||||
MultiMetric.createBindings(ids)
|
||||
])
|
||||
var m = Injector.resolveAndCreate([
|
||||
ids.map(id => provide(id, {useValue: new MockMetric(id)})),
|
||||
MultiMetric.createBindings(ids)
|
||||
])
|
||||
.get(MultiMetric);
|
||||
return PromiseWrapper.resolve(m);
|
||||
}
|
||||
|
||||
describe('multi metric', () => {
|
||||
it('should merge descriptions', inject([AsyncTestCompleter], (async) => {
|
||||
createMetric(['m1', 'm2']).then((m) => {
|
||||
expect(m.describe()).toEqual({'m1': 'describe', 'm2': 'describe'});
|
||||
async.done();
|
||||
});
|
||||
createMetric(['m1', 'm2'])
|
||||
.then((m) => {
|
||||
expect(m.describe()).toEqual({'m1': 'describe', 'm2': 'describe'});
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should merge all beginMeasure calls', inject([AsyncTestCompleter], (async) => {
|
||||
createMetric(['m1', 'm2']).then((m) => m.beginMeasure()).then((values) => {
|
||||
expect(values).toEqual(['m1_beginMeasure', 'm2_beginMeasure']);
|
||||
async.done();
|
||||
});
|
||||
createMetric(['m1', 'm2'])
|
||||
.then((m) => m.beginMeasure())
|
||||
.then((values) => {
|
||||
expect(values).toEqual(['m1_beginMeasure', 'm2_beginMeasure']);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
[false, true].forEach((restartFlag) => {
|
||||
it(`should merge all endMeasure calls for restart=${restartFlag}`,
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
createMetric(['m1', 'm2']).then((m) => m.endMeasure(restartFlag)).then((values) => {
|
||||
expect(values).toEqual(
|
||||
{'m1': {'restart': restartFlag}, 'm2': {'restart': restartFlag}});
|
||||
async.done();
|
||||
});
|
||||
createMetric(['m1', 'm2'])
|
||||
.then((m) => m.endMeasure(restartFlag))
|
||||
.then((values) => {
|
||||
expect(values)
|
||||
.toEqual({'m1': {'restart': restartFlag}, 'm2': {'restart': restartFlag}});
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
|
@ -1,10 +1,30 @@
|
||||
import {afterEach, AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from 'angular2/testing_internal';
|
||||
import {
|
||||
afterEach,
|
||||
AsyncTestCompleter,
|
||||
beforeEach,
|
||||
ddescribe,
|
||||
describe,
|
||||
expect,
|
||||
iit,
|
||||
inject,
|
||||
it,
|
||||
xit,
|
||||
} from 'angular2/testing_internal';
|
||||
|
||||
import {StringMapWrapper} from 'angular2/src/facade/collection';
|
||||
import {PromiseWrapper} from 'angular2/src/facade/async';
|
||||
import {isPresent, isBlank} from 'angular2/src/facade/lang';
|
||||
|
||||
import {Metric, PerflogMetric, WebDriverExtension, PerfLogFeatures, bind, provide, Injector, Options} from 'benchpress/common';
|
||||
import {
|
||||
Metric,
|
||||
PerflogMetric,
|
||||
WebDriverExtension,
|
||||
PerfLogFeatures,
|
||||
bind,
|
||||
provide,
|
||||
Injector,
|
||||
Options
|
||||
} from 'benchpress/common';
|
||||
|
||||
import {TraceEventFactory} from '../trace_event_factory';
|
||||
|
||||
@ -12,15 +32,14 @@ export function main() {
|
||||
var commandLog: any[];
|
||||
var eventFactory = new TraceEventFactory('timeline', 'pid0');
|
||||
|
||||
function createMetric(
|
||||
perfLogs, perfLogFeatures,
|
||||
{microMetrics, forceGc, captureFrames, receivedData, requestCount}: {
|
||||
microMetrics?: {[key: string]: string},
|
||||
forceGc?: boolean,
|
||||
captureFrames?: boolean,
|
||||
receivedData?: boolean,
|
||||
requestCount?: boolean
|
||||
} = {}): Metric {
|
||||
function createMetric(perfLogs, perfLogFeatures,
|
||||
{microMetrics, forceGc, captureFrames, receivedData, requestCount}: {
|
||||
microMetrics?: {[key: string]: string},
|
||||
forceGc?: boolean,
|
||||
captureFrames?: boolean,
|
||||
receivedData?: boolean,
|
||||
requestCount?: boolean
|
||||
} = {}): Metric {
|
||||
commandLog = [];
|
||||
if (isBlank(perfLogFeatures)) {
|
||||
perfLogFeatures =
|
||||
@ -30,12 +49,14 @@ export function main() {
|
||||
microMetrics = StringMapWrapper.create();
|
||||
}
|
||||
var bindings = [
|
||||
Options.DEFAULT_PROVIDERS, PerflogMetric.BINDINGS,
|
||||
Options.DEFAULT_PROVIDERS,
|
||||
PerflogMetric.BINDINGS,
|
||||
bind(Options.MICRO_METRICS).toValue(microMetrics),
|
||||
bind(PerflogMetric.SET_TIMEOUT).toValue((fn, millis) => {
|
||||
commandLog.push(['setTimeout', millis]);
|
||||
fn();
|
||||
}),
|
||||
bind(PerflogMetric.SET_TIMEOUT)
|
||||
.toValue((fn, millis) => {
|
||||
commandLog.push(['setTimeout', millis]);
|
||||
fn();
|
||||
}),
|
||||
bind(WebDriverExtension)
|
||||
.toValue(new MockDriverExtension(perfLogs, commandLog, perfLogFeatures))
|
||||
];
|
||||
@ -64,31 +85,35 @@ export function main() {
|
||||
}
|
||||
|
||||
it('should describe itself based on the perfLogFeatrues', () => {
|
||||
expect(sortedKeys(createMetric([[]], new PerfLogFeatures()).describe())).toEqual([
|
||||
'pureScriptTime', 'scriptTime'
|
||||
]);
|
||||
expect(sortedKeys(createMetric([[]], new PerfLogFeatures()).describe()))
|
||||
.toEqual(['pureScriptTime', 'scriptTime']);
|
||||
|
||||
expect(
|
||||
sortedKeys(createMetric([[]], new PerfLogFeatures({render: true, gc: false})).describe()))
|
||||
.toEqual(['pureScriptTime', 'renderTime', 'scriptTime']);
|
||||
|
||||
expect(sortedKeys(createMetric([[]], null).describe())).toEqual([
|
||||
'gcAmount', 'gcTime', 'majorGcTime', 'pureScriptTime', 'renderTime', 'scriptTime'
|
||||
]);
|
||||
expect(sortedKeys(createMetric([[]], null).describe()))
|
||||
.toEqual(
|
||||
['gcAmount', 'gcTime', 'majorGcTime', 'pureScriptTime', 'renderTime', 'scriptTime']);
|
||||
|
||||
expect(sortedKeys(createMetric([[]], new PerfLogFeatures({render: true, gc: true}), {
|
||||
forceGc: true
|
||||
}).describe()))
|
||||
expect(sortedKeys(
|
||||
createMetric([[]], new PerfLogFeatures({render: true, gc: true}), {forceGc: true})
|
||||
.describe()))
|
||||
.toEqual([
|
||||
'forcedGcAmount', 'forcedGcTime', 'gcAmount', 'gcTime', 'majorGcTime', 'pureScriptTime',
|
||||
'renderTime', 'scriptTime'
|
||||
'forcedGcAmount',
|
||||
'forcedGcTime',
|
||||
'gcAmount',
|
||||
'gcTime',
|
||||
'majorGcTime',
|
||||
'pureScriptTime',
|
||||
'renderTime',
|
||||
'scriptTime'
|
||||
]);
|
||||
|
||||
|
||||
expect(sortedKeys(createMetric([[]], new PerfLogFeatures({userTiming: true}), {
|
||||
receivedData: true,
|
||||
requestCount: true
|
||||
}).describe()))
|
||||
expect(sortedKeys(createMetric([[]], new PerfLogFeatures({userTiming: true}),
|
||||
{receivedData: true, requestCount: true})
|
||||
.describe()))
|
||||
.toEqual(['pureScriptTime', 'receivedData', 'requestCount', 'scriptTime']);
|
||||
});
|
||||
|
||||
@ -99,9 +124,9 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should describe itself if frame capture is requested and available', () => {
|
||||
var description = createMetric([[]], new PerfLogFeatures({frameCapture: true}), {
|
||||
captureFrames: true
|
||||
}).describe();
|
||||
var description =
|
||||
createMetric([[]], new PerfLogFeatures({frameCapture: true}), {captureFrames: true})
|
||||
.describe();
|
||||
expect(description['frameTime.mean']).not.toContain('WARNING');
|
||||
expect(description['frameTime.best']).not.toContain('WARNING');
|
||||
expect(description['frameTime.worst']).not.toContain('WARNING');
|
||||
@ -109,9 +134,9 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should describe itself if frame capture is requested and not available', () => {
|
||||
var description = createMetric([[]], new PerfLogFeatures({frameCapture: false}), {
|
||||
captureFrames: true
|
||||
}).describe();
|
||||
var description =
|
||||
createMetric([[]], new PerfLogFeatures({frameCapture: false}), {captureFrames: true})
|
||||
.describe();
|
||||
expect(description['frameTime.mean']).toContain('WARNING');
|
||||
expect(description['frameTime.best']).toContain('WARNING');
|
||||
expect(description['frameTime.worst']).toContain('WARNING');
|
||||
@ -144,19 +169,28 @@ export function main() {
|
||||
|
||||
it('should mark and aggregate events in between the marks',
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
var events = [[
|
||||
eventFactory.markStart('benchpress0', 0), eventFactory.start('script', 4),
|
||||
eventFactory.end('script', 6), eventFactory.markEnd('benchpress0', 10)
|
||||
]];
|
||||
var events = [
|
||||
[
|
||||
eventFactory.markStart('benchpress0', 0),
|
||||
eventFactory.start('script', 4),
|
||||
eventFactory.end('script', 6),
|
||||
eventFactory.markEnd('benchpress0', 10)
|
||||
]
|
||||
];
|
||||
var metric = createMetric(events, null);
|
||||
metric.beginMeasure().then((_) => metric.endMeasure(false)).then((data) => {
|
||||
expect(commandLog).toEqual([
|
||||
['timeBegin', 'benchpress0'], ['timeEnd', 'benchpress0', null], 'readPerfLog'
|
||||
]);
|
||||
expect(data['scriptTime']).toBe(2);
|
||||
metric.beginMeasure()
|
||||
.then((_) => metric.endMeasure(false))
|
||||
.then((data) => {
|
||||
expect(commandLog)
|
||||
.toEqual([
|
||||
['timeBegin', 'benchpress0'],
|
||||
['timeEnd', 'benchpress0', null],
|
||||
'readPerfLog'
|
||||
]);
|
||||
expect(data['scriptTime']).toBe(2);
|
||||
|
||||
async.done();
|
||||
});
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should restart timing', inject([AsyncTestCompleter], (async) => {
|
||||
@ -173,10 +207,14 @@ export function main() {
|
||||
.then((_) => metric.endMeasure(true))
|
||||
.then((_) => metric.endMeasure(true))
|
||||
.then((_) => {
|
||||
expect(commandLog).toEqual([
|
||||
['timeBegin', 'benchpress0'], ['timeEnd', 'benchpress0', 'benchpress1'],
|
||||
'readPerfLog', ['timeEnd', 'benchpress1', 'benchpress2'], 'readPerfLog'
|
||||
]);
|
||||
expect(commandLog)
|
||||
.toEqual([
|
||||
['timeBegin', 'benchpress0'],
|
||||
['timeEnd', 'benchpress0', 'benchpress1'],
|
||||
'readPerfLog',
|
||||
['timeEnd', 'benchpress1', 'benchpress2'],
|
||||
'readPerfLog'
|
||||
]);
|
||||
|
||||
async.done();
|
||||
});
|
||||
@ -188,32 +226,44 @@ export function main() {
|
||||
[eventFactory.markStart('benchpress0', 0), eventFactory.start('script', 1)],
|
||||
[eventFactory.end('script', 2)],
|
||||
[
|
||||
eventFactory.start('script', 3), eventFactory.end('script', 5),
|
||||
eventFactory.start('script', 3),
|
||||
eventFactory.end('script', 5),
|
||||
eventFactory.markEnd('benchpress0', 10)
|
||||
]
|
||||
];
|
||||
var metric = createMetric(events, null);
|
||||
metric.beginMeasure().then((_) => metric.endMeasure(false)).then((data) => {
|
||||
expect(commandLog).toEqual([
|
||||
['timeBegin', 'benchpress0'], ['timeEnd', 'benchpress0', null], 'readPerfLog',
|
||||
['setTimeout', 100], 'readPerfLog', ['setTimeout', 100], 'readPerfLog'
|
||||
]);
|
||||
expect(data['scriptTime']).toBe(3);
|
||||
metric.beginMeasure()
|
||||
.then((_) => metric.endMeasure(false))
|
||||
.then((data) => {
|
||||
expect(commandLog)
|
||||
.toEqual([
|
||||
['timeBegin', 'benchpress0'],
|
||||
['timeEnd', 'benchpress0', null],
|
||||
'readPerfLog',
|
||||
['setTimeout', 100],
|
||||
'readPerfLog',
|
||||
['setTimeout', 100],
|
||||
'readPerfLog'
|
||||
]);
|
||||
expect(data['scriptTime']).toBe(3);
|
||||
|
||||
async.done();
|
||||
});
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should store events after the end mark for the next call',
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
var events = [
|
||||
[
|
||||
eventFactory.markStart('benchpress0', 0), eventFactory.markEnd('benchpress0', 1),
|
||||
eventFactory.markStart('benchpress1', 1), eventFactory.start('script', 1),
|
||||
eventFactory.markStart('benchpress0', 0),
|
||||
eventFactory.markEnd('benchpress0', 1),
|
||||
eventFactory.markStart('benchpress1', 1),
|
||||
eventFactory.start('script', 1),
|
||||
eventFactory.end('script', 2)
|
||||
],
|
||||
[
|
||||
eventFactory.start('script', 3), eventFactory.end('script', 5),
|
||||
eventFactory.start('script', 3),
|
||||
eventFactory.end('script', 5),
|
||||
eventFactory.markEnd('benchpress1', 6)
|
||||
]
|
||||
];
|
||||
@ -225,10 +275,14 @@ export function main() {
|
||||
return metric.endMeasure(true)
|
||||
})
|
||||
.then((data) => {
|
||||
expect(commandLog).toEqual([
|
||||
['timeBegin', 'benchpress0'], ['timeEnd', 'benchpress0', 'benchpress1'],
|
||||
'readPerfLog', ['timeEnd', 'benchpress1', 'benchpress2'], 'readPerfLog'
|
||||
]);
|
||||
expect(commandLog)
|
||||
.toEqual([
|
||||
['timeBegin', 'benchpress0'],
|
||||
['timeEnd', 'benchpress0', 'benchpress1'],
|
||||
'readPerfLog',
|
||||
['timeEnd', 'benchpress1', 'benchpress2'],
|
||||
'readPerfLog'
|
||||
]);
|
||||
expect(data['scriptTime']).toBe(3);
|
||||
|
||||
async.done();
|
||||
@ -238,37 +292,51 @@ export function main() {
|
||||
describe('with forced gc', () => {
|
||||
var events;
|
||||
beforeEach(() => {
|
||||
events = [[
|
||||
eventFactory.markStart('benchpress0', 0), eventFactory.start('script', 4),
|
||||
eventFactory.end('script', 6), eventFactory.markEnd('benchpress0', 10),
|
||||
eventFactory.markStart('benchpress1', 11),
|
||||
eventFactory.start('gc', 12, {'usedHeapSize': 2500}),
|
||||
eventFactory.end('gc', 15, {'usedHeapSize': 1000}),
|
||||
eventFactory.markEnd('benchpress1', 20)
|
||||
]];
|
||||
events = [
|
||||
[
|
||||
eventFactory.markStart('benchpress0', 0),
|
||||
eventFactory.start('script', 4),
|
||||
eventFactory.end('script', 6),
|
||||
eventFactory.markEnd('benchpress0', 10),
|
||||
eventFactory.markStart('benchpress1', 11),
|
||||
eventFactory.start('gc', 12, {'usedHeapSize': 2500}),
|
||||
eventFactory.end('gc', 15, {'usedHeapSize': 1000}),
|
||||
eventFactory.markEnd('benchpress1', 20)
|
||||
]
|
||||
];
|
||||
});
|
||||
|
||||
it('should measure forced gc', inject([AsyncTestCompleter], (async) => {
|
||||
var metric = createMetric(events, null, {forceGc: true});
|
||||
metric.beginMeasure().then((_) => metric.endMeasure(false)).then((data) => {
|
||||
expect(commandLog).toEqual([
|
||||
['gc'], ['timeBegin', 'benchpress0'], ['timeEnd', 'benchpress0', 'benchpress1'],
|
||||
'readPerfLog', ['gc'], ['timeEnd', 'benchpress1', null], 'readPerfLog'
|
||||
]);
|
||||
expect(data['forcedGcTime']).toBe(3);
|
||||
expect(data['forcedGcAmount']).toBe(1.5);
|
||||
metric.beginMeasure()
|
||||
.then((_) => metric.endMeasure(false))
|
||||
.then((data) => {
|
||||
expect(commandLog)
|
||||
.toEqual([
|
||||
['gc'],
|
||||
['timeBegin', 'benchpress0'],
|
||||
['timeEnd', 'benchpress0', 'benchpress1'],
|
||||
'readPerfLog',
|
||||
['gc'],
|
||||
['timeEnd', 'benchpress1', null],
|
||||
'readPerfLog'
|
||||
]);
|
||||
expect(data['forcedGcTime']).toBe(3);
|
||||
expect(data['forcedGcAmount']).toBe(1.5);
|
||||
|
||||
async.done();
|
||||
});
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should restart after the forced gc if needed', inject([AsyncTestCompleter], (async) => {
|
||||
var metric = createMetric(events, null, {forceGc: true});
|
||||
metric.beginMeasure().then((_) => metric.endMeasure(true)).then((data) => {
|
||||
expect(commandLog[5]).toEqual(['timeEnd', 'benchpress1', 'benchpress2']);
|
||||
metric.beginMeasure()
|
||||
.then((_) => metric.endMeasure(true))
|
||||
.then((data) => {
|
||||
expect(commandLog[5]).toEqual(['timeEnd', 'benchpress1', 'benchpress2']);
|
||||
|
||||
async.done();
|
||||
});
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
});
|
||||
@ -298,8 +366,10 @@ export function main() {
|
||||
it('should calculate mean frame time', inject([AsyncTestCompleter], (async) => {
|
||||
aggregate(
|
||||
[
|
||||
eventFactory.markStart('frameCapture', 0), eventFactory.instant('frame', 1),
|
||||
eventFactory.instant('frame', 3), eventFactory.instant('frame', 4),
|
||||
eventFactory.markStart('frameCapture', 0),
|
||||
eventFactory.instant('frame', 1),
|
||||
eventFactory.instant('frame', 3),
|
||||
eventFactory.instant('frame', 4),
|
||||
eventFactory.markEnd('frameCapture', 5)
|
||||
],
|
||||
{captureFrames: true})
|
||||
@ -315,9 +385,8 @@ export function main() {
|
||||
[eventFactory.instant('frame', 4), eventFactory.markEnd('frameCapture', 5)],
|
||||
{captureFrames: true}),
|
||||
(err): any => {
|
||||
expect(() => {
|
||||
throw err;
|
||||
}).toThrowError('missing start event for frame capture');
|
||||
expect(() => { throw err; })
|
||||
.toThrowError('missing start event for frame capture');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@ -342,9 +411,8 @@ export function main() {
|
||||
],
|
||||
{captureFrames: true}),
|
||||
(err): any => {
|
||||
expect(() => {
|
||||
throw err;
|
||||
}).toThrowError('can capture frames only once per benchmark run');
|
||||
expect(() => { throw err; })
|
||||
.toThrowError('can capture frames only once per benchmark run');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@ -373,10 +441,14 @@ export function main() {
|
||||
it('should calculate best and worst frame time', inject([AsyncTestCompleter], (async) => {
|
||||
aggregate(
|
||||
[
|
||||
eventFactory.markStart('frameCapture', 0), eventFactory.instant('frame', 1),
|
||||
eventFactory.instant('frame', 9), eventFactory.instant('frame', 15),
|
||||
eventFactory.instant('frame', 18), eventFactory.instant('frame', 28),
|
||||
eventFactory.instant('frame', 32), eventFactory.markEnd('frameCapture', 10)
|
||||
eventFactory.markStart('frameCapture', 0),
|
||||
eventFactory.instant('frame', 1),
|
||||
eventFactory.instant('frame', 9),
|
||||
eventFactory.instant('frame', 15),
|
||||
eventFactory.instant('frame', 18),
|
||||
eventFactory.instant('frame', 28),
|
||||
eventFactory.instant('frame', 32),
|
||||
eventFactory.markEnd('frameCapture', 10)
|
||||
],
|
||||
{captureFrames: true})
|
||||
.then((data) => {
|
||||
@ -390,8 +462,10 @@ export function main() {
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
aggregate(
|
||||
[
|
||||
eventFactory.markStart('frameCapture', 0), eventFactory.instant('frame', 1),
|
||||
eventFactory.instant('frame', 2), eventFactory.instant('frame', 3),
|
||||
eventFactory.markStart('frameCapture', 0),
|
||||
eventFactory.instant('frame', 1),
|
||||
eventFactory.instant('frame', 2),
|
||||
eventFactory.instant('frame', 3),
|
||||
eventFactory.markEnd('frameCapture', 4)
|
||||
],
|
||||
{captureFrames: true})
|
||||
@ -405,9 +479,12 @@ export function main() {
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
aggregate(
|
||||
[
|
||||
eventFactory.markStart('frameCapture', 0), eventFactory.instant('frame', 1),
|
||||
eventFactory.instant('frame', 2), eventFactory.instant('frame', 22),
|
||||
eventFactory.instant('frame', 23), eventFactory.instant('frame', 24),
|
||||
eventFactory.markStart('frameCapture', 0),
|
||||
eventFactory.instant('frame', 1),
|
||||
eventFactory.instant('frame', 2),
|
||||
eventFactory.instant('frame', 22),
|
||||
eventFactory.instant('frame', 23),
|
||||
eventFactory.instant('frame', 24),
|
||||
eventFactory.markEnd('frameCapture', 4)
|
||||
],
|
||||
{captureFrames: true})
|
||||
@ -420,160 +497,173 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should report a single interval', inject([AsyncTestCompleter], (async) => {
|
||||
aggregate([
|
||||
eventFactory.start('script', 0), eventFactory.end('script', 5)
|
||||
]).then((data) => {
|
||||
expect(data['scriptTime']).toBe(5);
|
||||
async.done();
|
||||
});
|
||||
aggregate([eventFactory.start('script', 0), eventFactory.end('script', 5)])
|
||||
.then((data) => {
|
||||
expect(data['scriptTime']).toBe(5);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should sum up multiple intervals', inject([AsyncTestCompleter], (async) => {
|
||||
aggregate([
|
||||
eventFactory.start('script', 0), eventFactory.end('script', 5),
|
||||
eventFactory.start('script', 10), eventFactory.end('script', 17)
|
||||
]).then((data) => {
|
||||
expect(data['scriptTime']).toBe(12);
|
||||
async.done();
|
||||
});
|
||||
eventFactory.start('script', 0),
|
||||
eventFactory.end('script', 5),
|
||||
eventFactory.start('script', 10),
|
||||
eventFactory.end('script', 17)
|
||||
])
|
||||
.then((data) => {
|
||||
expect(data['scriptTime']).toBe(12);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should ignore not started intervals', inject([AsyncTestCompleter], (async) => {
|
||||
aggregate([eventFactory.end('script', 10)]).then((data) => {
|
||||
expect(data['scriptTime']).toBe(0);
|
||||
async.done();
|
||||
});
|
||||
aggregate([eventFactory.end('script', 10)])
|
||||
.then((data) => {
|
||||
expect(data['scriptTime']).toBe(0);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should ignore not ended intervals', inject([AsyncTestCompleter], (async) => {
|
||||
aggregate([eventFactory.start('script', 10)]).then((data) => {
|
||||
expect(data['scriptTime']).toBe(0);
|
||||
async.done();
|
||||
});
|
||||
aggregate([eventFactory.start('script', 10)])
|
||||
.then((data) => {
|
||||
expect(data['scriptTime']).toBe(0);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should ignore nested intervals', inject([AsyncTestCompleter], (async) => {
|
||||
aggregate([
|
||||
eventFactory.start('script', 0), eventFactory.start('script', 5),
|
||||
eventFactory.end('script', 10), eventFactory.end('script', 17)
|
||||
]).then((data) => {
|
||||
expect(data['scriptTime']).toBe(17);
|
||||
async.done();
|
||||
});
|
||||
eventFactory.start('script', 0),
|
||||
eventFactory.start('script', 5),
|
||||
eventFactory.end('script', 10),
|
||||
eventFactory.end('script', 17)
|
||||
])
|
||||
.then((data) => {
|
||||
expect(data['scriptTime']).toBe(17);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should ignore events from different processed as the start mark',
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
var otherProcessEventFactory = new TraceEventFactory('timeline', 'pid1');
|
||||
var metric = createMetric(
|
||||
[[
|
||||
eventFactory.markStart('benchpress0', 0), eventFactory.start('script', 0, null),
|
||||
eventFactory.end('script', 5, null),
|
||||
otherProcessEventFactory.start('script', 10, null),
|
||||
otherProcessEventFactory.end('script', 17, null),
|
||||
eventFactory.markEnd('benchpress0', 20)
|
||||
]],
|
||||
[
|
||||
[
|
||||
eventFactory.markStart('benchpress0', 0),
|
||||
eventFactory.start('script', 0, null),
|
||||
eventFactory.end('script', 5, null),
|
||||
otherProcessEventFactory.start('script', 10, null),
|
||||
otherProcessEventFactory.end('script', 17, null),
|
||||
eventFactory.markEnd('benchpress0', 20)
|
||||
]
|
||||
],
|
||||
null);
|
||||
metric.beginMeasure().then((_) => metric.endMeasure(false)).then((data) => {
|
||||
expect(data['scriptTime']).toBe(5);
|
||||
async.done();
|
||||
});
|
||||
metric.beginMeasure()
|
||||
.then((_) => metric.endMeasure(false))
|
||||
.then((data) => {
|
||||
expect(data['scriptTime']).toBe(5);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should support scriptTime metric', inject([AsyncTestCompleter], (async) => {
|
||||
aggregate([
|
||||
eventFactory.start('script', 0), eventFactory.end('script', 5)
|
||||
]).then((data) => {
|
||||
expect(data['scriptTime']).toBe(5);
|
||||
async.done();
|
||||
});
|
||||
aggregate([eventFactory.start('script', 0), eventFactory.end('script', 5)])
|
||||
.then((data) => {
|
||||
expect(data['scriptTime']).toBe(5);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should support renderTime metric', inject([AsyncTestCompleter], (async) => {
|
||||
aggregate([
|
||||
eventFactory.start('render', 0), eventFactory.end('render', 5)
|
||||
]).then((data) => {
|
||||
expect(data['renderTime']).toBe(5);
|
||||
async.done();
|
||||
});
|
||||
aggregate([eventFactory.start('render', 0), eventFactory.end('render', 5)])
|
||||
.then((data) => {
|
||||
expect(data['renderTime']).toBe(5);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should support gcTime/gcAmount metric', inject([AsyncTestCompleter], (async) => {
|
||||
aggregate([
|
||||
eventFactory.start('gc', 0, {'usedHeapSize': 2500}),
|
||||
eventFactory.end('gc', 5, {'usedHeapSize': 1000})
|
||||
]).then((data) => {
|
||||
expect(data['gcTime']).toBe(5);
|
||||
expect(data['gcAmount']).toBe(1.5);
|
||||
expect(data['majorGcTime']).toBe(0);
|
||||
async.done();
|
||||
});
|
||||
])
|
||||
.then((data) => {
|
||||
expect(data['gcTime']).toBe(5);
|
||||
expect(data['gcAmount']).toBe(1.5);
|
||||
expect(data['majorGcTime']).toBe(0);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should support majorGcTime metric', inject([AsyncTestCompleter], (async) => {
|
||||
aggregate([
|
||||
eventFactory.start('gc', 0, {'usedHeapSize': 2500}),
|
||||
eventFactory.end('gc', 5, {'usedHeapSize': 1000, 'majorGc': true})
|
||||
]).then((data) => {
|
||||
expect(data['gcTime']).toBe(5);
|
||||
expect(data['majorGcTime']).toBe(5);
|
||||
async.done();
|
||||
});
|
||||
])
|
||||
.then((data) => {
|
||||
expect(data['gcTime']).toBe(5);
|
||||
expect(data['majorGcTime']).toBe(5);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should support pureScriptTime = scriptTime-gcTime-renderTime',
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
aggregate([
|
||||
eventFactory.start('script', 0), eventFactory.start('gc', 1, {'usedHeapSize': 1000}),
|
||||
eventFactory.end('gc', 4, {'usedHeapSize': 0}), eventFactory.start('render', 4),
|
||||
eventFactory.end('render', 5), eventFactory.end('script', 6)
|
||||
]).then((data) => {
|
||||
expect(data['scriptTime']).toBe(6);
|
||||
expect(data['pureScriptTime']).toBe(2);
|
||||
async.done();
|
||||
});
|
||||
eventFactory.start('script', 0),
|
||||
eventFactory.start('gc', 1, {'usedHeapSize': 1000}),
|
||||
eventFactory.end('gc', 4, {'usedHeapSize': 0}),
|
||||
eventFactory.start('render', 4),
|
||||
eventFactory.end('render', 5),
|
||||
eventFactory.end('script', 6)
|
||||
])
|
||||
.then((data) => {
|
||||
expect(data['scriptTime']).toBe(6);
|
||||
expect(data['pureScriptTime']).toBe(2);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
describe(
|
||||
'receivedData',
|
||||
() => {
|
||||
it('should report received data since last navigationStart',
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
aggregate(
|
||||
[
|
||||
eventFactory.instant('receivedData', 0, {'encodedDataLength': 1}),
|
||||
eventFactory.instant('navigationStart', 1),
|
||||
eventFactory.instant('receivedData', 2, {'encodedDataLength': 2}),
|
||||
eventFactory.instant('navigationStart', 3),
|
||||
eventFactory.instant('receivedData', 4, {'encodedDataLength': 4}),
|
||||
eventFactory.instant('receivedData', 5, {'encodedDataLength': 8})
|
||||
],
|
||||
{receivedData: true})
|
||||
.then((data) => {
|
||||
expect(data['receivedData']).toBe(12);
|
||||
async.done();
|
||||
});
|
||||
}))});
|
||||
describe('receivedData',
|
||||
() => {it('should report received data since last navigationStart',
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
aggregate(
|
||||
[
|
||||
eventFactory.instant('receivedData', 0, {'encodedDataLength': 1}),
|
||||
eventFactory.instant('navigationStart', 1),
|
||||
eventFactory.instant('receivedData', 2, {'encodedDataLength': 2}),
|
||||
eventFactory.instant('navigationStart', 3),
|
||||
eventFactory.instant('receivedData', 4, {'encodedDataLength': 4}),
|
||||
eventFactory.instant('receivedData', 5, {'encodedDataLength': 8})
|
||||
],
|
||||
{receivedData: true})
|
||||
.then((data) => {
|
||||
expect(data['receivedData']).toBe(12);
|
||||
async.done();
|
||||
});
|
||||
}))});
|
||||
|
||||
describe(
|
||||
'requestCount',
|
||||
() => {it(
|
||||
'should report count of requests sent since last navigationStart',
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
aggregate(
|
||||
[
|
||||
eventFactory.instant('sendRequest', 0),
|
||||
eventFactory.instant('navigationStart', 1),
|
||||
eventFactory.instant('sendRequest', 2),
|
||||
eventFactory.instant('navigationStart', 3),
|
||||
eventFactory.instant('sendRequest', 4), eventFactory.instant('sendRequest', 5)
|
||||
],
|
||||
{requestCount: true})
|
||||
.then((data) => {
|
||||
expect(data['requestCount']).toBe(2);
|
||||
async.done();
|
||||
});
|
||||
}))});
|
||||
describe('requestCount',
|
||||
() => {it('should report count of requests sent since last navigationStart',
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
aggregate(
|
||||
[
|
||||
eventFactory.instant('sendRequest', 0),
|
||||
eventFactory.instant('navigationStart', 1),
|
||||
eventFactory.instant('sendRequest', 2),
|
||||
eventFactory.instant('navigationStart', 3),
|
||||
eventFactory.instant('sendRequest', 4),
|
||||
eventFactory.instant('sendRequest', 5)
|
||||
],
|
||||
{requestCount: true})
|
||||
.then((data) => {
|
||||
expect(data['requestCount']).toBe(2);
|
||||
async.done();
|
||||
});
|
||||
}))});
|
||||
|
||||
describe('microMetrics', () => {
|
||||
|
||||
@ -595,10 +685,11 @@ export function main() {
|
||||
aggregate([
|
||||
eventFactory.markStart('mm1', 0),
|
||||
eventFactory.markEnd('mm1', 5),
|
||||
]).then((data) => {
|
||||
expect(data['mm1']).toBeFalsy();
|
||||
async.done();
|
||||
});
|
||||
])
|
||||
.then((data) => {
|
||||
expect(data['mm1']).toBeFalsy();
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should report micro metric averages', inject([AsyncTestCompleter], (async) => {
|
||||
@ -622,9 +713,8 @@ export function main() {
|
||||
}
|
||||
|
||||
class MockDriverExtension extends WebDriverExtension {
|
||||
constructor(
|
||||
private _perfLogs: any[], private _commandLog: any[],
|
||||
private _perfLogFeatures: PerfLogFeatures) {
|
||||
constructor(private _perfLogs: any[], private _commandLog: any[],
|
||||
private _perfLogFeatures: PerfLogFeatures) {
|
||||
super();
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,26 @@
|
||||
import {describe, ddescribe, it, iit, xit, expect, beforeEach, afterEach} from 'angular2/testing_internal';
|
||||
import {
|
||||
describe,
|
||||
ddescribe,
|
||||
it,
|
||||
iit,
|
||||
xit,
|
||||
expect,
|
||||
beforeEach,
|
||||
afterEach
|
||||
} from 'angular2/testing_internal';
|
||||
|
||||
import {isBlank, isPresent, Date, DateWrapper} from 'angular2/src/facade/lang';
|
||||
|
||||
import {SampleState, Reporter, bind, provide, Injector, ConsoleReporter, SampleDescription, MeasureValues} from 'benchpress/common';
|
||||
import {
|
||||
SampleState,
|
||||
Reporter,
|
||||
bind,
|
||||
provide,
|
||||
Injector,
|
||||
ConsoleReporter,
|
||||
SampleDescription,
|
||||
MeasureValues
|
||||
} from 'benchpress/common';
|
||||
|
||||
export function main() {
|
||||
describe('console reporter', () => {
|
||||
@ -20,8 +38,8 @@ export function main() {
|
||||
}
|
||||
var bindings = [
|
||||
ConsoleReporter.BINDINGS,
|
||||
provide(
|
||||
SampleDescription, {useValue: new SampleDescription(sampleId, descriptions, metrics)}),
|
||||
provide(SampleDescription,
|
||||
{useValue: new SampleDescription(sampleId, descriptions, metrics)}),
|
||||
bind(ConsoleReporter.PRINT).toValue((line) => log.push(line))
|
||||
];
|
||||
if (isPresent(columnWidth)) {
|
||||
|
@ -1,9 +1,27 @@
|
||||
import {afterEach, AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from 'angular2/testing_internal';
|
||||
import {
|
||||
afterEach,
|
||||
AsyncTestCompleter,
|
||||
beforeEach,
|
||||
ddescribe,
|
||||
describe,
|
||||
expect,
|
||||
iit,
|
||||
inject,
|
||||
it,
|
||||
xit,
|
||||
} from 'angular2/testing_internal';
|
||||
|
||||
import {DateWrapper, Json, RegExpWrapper, isPresent} from 'angular2/src/facade/lang';
|
||||
import {PromiseWrapper} from 'angular2/src/facade/async';
|
||||
|
||||
import {bind, provide, Injector, SampleDescription, MeasureValues, Options} from 'benchpress/common';
|
||||
import {
|
||||
bind,
|
||||
provide,
|
||||
Injector,
|
||||
SampleDescription,
|
||||
MeasureValues,
|
||||
Options
|
||||
} from 'benchpress/common';
|
||||
|
||||
|
||||
import {JsonFileReporter} from 'benchpress/src/reporter/json_file_reporter';
|
||||
@ -15,14 +33,15 @@ export function main() {
|
||||
function createReporter({sampleId, descriptions, metrics, path}) {
|
||||
var bindings = [
|
||||
JsonFileReporter.BINDINGS,
|
||||
provide(
|
||||
SampleDescription, {useValue: new SampleDescription(sampleId, descriptions, metrics)}),
|
||||
provide(SampleDescription,
|
||||
{useValue: new SampleDescription(sampleId, descriptions, metrics)}),
|
||||
bind(JsonFileReporter.PATH).toValue(path),
|
||||
bind(Options.NOW).toValue(() => DateWrapper.fromMillis(1234)),
|
||||
bind(Options.WRITE_FILE).toValue((filename, content) => {
|
||||
loggedFile = {'filename': filename, 'content': content};
|
||||
return PromiseWrapper.resolve(null);
|
||||
})
|
||||
bind(Options.WRITE_FILE)
|
||||
.toValue((filename, content) => {
|
||||
loggedFile = {'filename': filename, 'content': content};
|
||||
return PromiseWrapper.resolve(null);
|
||||
})
|
||||
];
|
||||
return Injector.resolveAndCreate(bindings).get(JsonFileReporter);
|
||||
}
|
||||
@ -34,26 +53,35 @@ export function main() {
|
||||
path: 'somePath',
|
||||
metrics: {'script': 'script time'}
|
||||
})
|
||||
.reportSample(
|
||||
[mv(0, 0, {'a': 3, 'b': 6})],
|
||||
[mv(0, 0, {'a': 3, 'b': 6}), mv(1, 1, {'a': 5, 'b': 9})]);
|
||||
.reportSample([mv(0, 0, {'a': 3, 'b': 6})],
|
||||
[mv(0, 0, {'a': 3, 'b': 6}), mv(1, 1, {'a': 5, 'b': 9})]);
|
||||
var regExp = /somePath\/someId_\d+\.json/g;
|
||||
expect(isPresent(RegExpWrapper.firstMatch(regExp, loggedFile['filename']))).toBe(true);
|
||||
var parsedContent = Json.parse(loggedFile['content']);
|
||||
expect(parsedContent).toEqual({
|
||||
'description':
|
||||
{'id': 'someId', 'description': {'a': 2}, 'metrics': {'script': 'script time'}},
|
||||
'completeSample': [
|
||||
{'timeStamp': '1970-01-01T00:00:00.000Z', 'runIndex': 0, 'values': {'a': 3, 'b': 6}}
|
||||
],
|
||||
'validSample': [
|
||||
{'timeStamp': '1970-01-01T00:00:00.000Z', 'runIndex': 0, 'values': {'a': 3, 'b': 6}}, {
|
||||
'timeStamp': '1970-01-01T00:00:00.001Z',
|
||||
'runIndex': 1,
|
||||
'values': {'a': 5, 'b': 9}
|
||||
}
|
||||
]
|
||||
});
|
||||
expect(parsedContent)
|
||||
.toEqual({
|
||||
"description":
|
||||
{"id": "someId", "description": {"a": 2}, "metrics": {"script": "script time"}},
|
||||
"completeSample": [
|
||||
{
|
||||
"timeStamp": "1970-01-01T00:00:00.000Z",
|
||||
"runIndex": 0,
|
||||
"values": {"a": 3, "b": 6}
|
||||
}
|
||||
],
|
||||
"validSample": [
|
||||
{
|
||||
"timeStamp": "1970-01-01T00:00:00.000Z",
|
||||
"runIndex": 0,
|
||||
"values": {"a": 3, "b": 6}
|
||||
},
|
||||
{
|
||||
"timeStamp": "1970-01-01T00:00:00.001Z",
|
||||
"runIndex": 1,
|
||||
"values": {"a": 5, "b": 9}
|
||||
}
|
||||
]
|
||||
});
|
||||
async.done();
|
||||
}));
|
||||
|
||||
|
@ -1,4 +1,15 @@
|
||||
import {afterEach, AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from 'angular2/testing_internal';
|
||||
import {
|
||||
afterEach,
|
||||
AsyncTestCompleter,
|
||||
beforeEach,
|
||||
ddescribe,
|
||||
describe,
|
||||
expect,
|
||||
iit,
|
||||
inject,
|
||||
it,
|
||||
xit,
|
||||
} from 'angular2/testing_internal';
|
||||
|
||||
import {PromiseWrapper} from 'angular2/src/facade/async';
|
||||
import {DateWrapper} from 'angular2/src/facade/lang';
|
||||
@ -7,11 +18,10 @@ import {Reporter, MultiReporter, bind, provide, Injector, MeasureValues} from 'b
|
||||
|
||||
export function main() {
|
||||
function createReporters(ids: any[]) {
|
||||
var r = Injector
|
||||
.resolveAndCreate([
|
||||
ids.map(id => provide(id, {useValue: new MockReporter(id)})),
|
||||
MultiReporter.createBindings(ids)
|
||||
])
|
||||
var r = Injector.resolveAndCreate([
|
||||
ids.map(id => provide(id, {useValue: new MockReporter(id)})),
|
||||
MultiReporter.createBindings(ids)
|
||||
])
|
||||
.get(MultiReporter);
|
||||
return PromiseWrapper.resolve(r);
|
||||
}
|
||||
@ -20,16 +30,19 @@ export function main() {
|
||||
|
||||
it('should reportMeasureValues to all', inject([AsyncTestCompleter], (async) => {
|
||||
var mv = new MeasureValues(0, DateWrapper.now(), {});
|
||||
createReporters(['m1', 'm2']).then((r) => r.reportMeasureValues(mv)).then((values) => {
|
||||
createReporters(['m1', 'm2'])
|
||||
.then((r) => r.reportMeasureValues(mv))
|
||||
.then((values) => {
|
||||
|
||||
expect(values).toEqual([{'id': 'm1', 'values': mv}, {'id': 'm2', 'values': mv}]);
|
||||
async.done();
|
||||
});
|
||||
expect(values).toEqual([{'id': 'm1', 'values': mv}, {'id': 'm2', 'values': mv}]);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should reportSample to call', inject([AsyncTestCompleter], (async) => {
|
||||
var completeSample = [
|
||||
new MeasureValues(0, DateWrapper.now(), {}), new MeasureValues(1, DateWrapper.now(), {})
|
||||
new MeasureValues(0, DateWrapper.now(), {}),
|
||||
new MeasureValues(1, DateWrapper.now(), {})
|
||||
];
|
||||
var validSample = [completeSample[1]];
|
||||
|
||||
@ -55,8 +68,8 @@ class MockReporter extends Reporter {
|
||||
return PromiseWrapper.resolve({'id': this._id, 'values': values});
|
||||
}
|
||||
|
||||
reportSample(completeSample: MeasureValues[], validSample: MeasureValues[]):
|
||||
Promise<{[key: string]: any}> {
|
||||
reportSample(completeSample: MeasureValues[],
|
||||
validSample: MeasureValues[]): Promise<{[key: string]: any}> {
|
||||
return PromiseWrapper.resolve(
|
||||
{'id': this._id, 'completeSample': completeSample, 'validSample': validSample});
|
||||
}
|
||||
|
@ -1,5 +1,28 @@
|
||||
import {afterEach, AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from 'angular2/testing_internal';
|
||||
import {Runner, Sampler, SampleDescription, Validator, bind, provide, Injector, Metric, Options, WebDriverAdapter, SampleState} from 'benchpress/common';
|
||||
import {
|
||||
afterEach,
|
||||
AsyncTestCompleter,
|
||||
beforeEach,
|
||||
ddescribe,
|
||||
describe,
|
||||
expect,
|
||||
iit,
|
||||
inject,
|
||||
it,
|
||||
xit,
|
||||
} from 'angular2/testing_internal';
|
||||
import {
|
||||
Runner,
|
||||
Sampler,
|
||||
SampleDescription,
|
||||
Validator,
|
||||
bind,
|
||||
provide,
|
||||
Injector,
|
||||
Metric,
|
||||
Options,
|
||||
WebDriverAdapter,
|
||||
SampleState
|
||||
} from 'benchpress/common';
|
||||
import {isBlank} from 'angular2/src/facade/lang';
|
||||
import {PromiseWrapper} from 'angular2/src/facade/async';
|
||||
|
||||
@ -13,12 +36,13 @@ export function main() {
|
||||
defaultBindings = [];
|
||||
}
|
||||
runner = new Runner([
|
||||
defaultBindings, bind(Sampler).toFactory(
|
||||
(_injector) => {
|
||||
injector = _injector;
|
||||
return new MockSampler();
|
||||
},
|
||||
[Injector]),
|
||||
defaultBindings,
|
||||
bind(Sampler).toFactory(
|
||||
(_injector) => {
|
||||
injector = _injector;
|
||||
return new MockSampler();
|
||||
},
|
||||
[Injector]),
|
||||
bind(Metric).toFactory(() => new MockMetric(), []),
|
||||
bind(Validator).toFactory(() => new MockValidator(), []),
|
||||
bind(WebDriverAdapter).toFactory(() => new MockWebDriverAdapter(), [])
|
||||
@ -62,35 +86,43 @@ export function main() {
|
||||
|
||||
it('should bind Options.EXECUTE', inject([AsyncTestCompleter], (async) => {
|
||||
var execute = () => {};
|
||||
createRunner().sample({id: 'someId', execute: execute}).then((_) => {
|
||||
expect(injector.get(Options.EXECUTE)).toEqual(execute);
|
||||
async.done();
|
||||
});
|
||||
createRunner()
|
||||
.sample({id: 'someId', execute: execute})
|
||||
.then((_) => {
|
||||
expect(injector.get(Options.EXECUTE)).toEqual(execute);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should bind Options.PREPARE', inject([AsyncTestCompleter], (async) => {
|
||||
var prepare = () => {};
|
||||
createRunner().sample({id: 'someId', prepare: prepare}).then((_) => {
|
||||
expect(injector.get(Options.PREPARE)).toEqual(prepare);
|
||||
async.done();
|
||||
});
|
||||
createRunner()
|
||||
.sample({id: 'someId', prepare: prepare})
|
||||
.then((_) => {
|
||||
expect(injector.get(Options.PREPARE)).toEqual(prepare);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should bind Options.MICRO_METRICS', inject([AsyncTestCompleter], (async) => {
|
||||
createRunner().sample({id: 'someId', microMetrics: {'a': 'b'}}).then((_) => {
|
||||
expect(injector.get(Options.MICRO_METRICS)).toEqual({'a': 'b'});
|
||||
async.done();
|
||||
});
|
||||
createRunner()
|
||||
.sample({id: 'someId', microMetrics: {'a': 'b'}})
|
||||
.then((_) => {
|
||||
expect(injector.get(Options.MICRO_METRICS)).toEqual({'a': 'b'});
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should overwrite bindings per sample call', inject([AsyncTestCompleter], (async) => {
|
||||
createRunner([
|
||||
bind(Options.DEFAULT_DESCRIPTION).toValue({'a': 1}),
|
||||
bind(Options.DEFAULT_DESCRIPTION)
|
||||
.toValue({'a': 1}),
|
||||
])
|
||||
.sample({
|
||||
id: 'someId',
|
||||
bindings: [
|
||||
bind(Options.DEFAULT_DESCRIPTION).toValue({'a': 2}),
|
||||
bind(Options.DEFAULT_DESCRIPTION)
|
||||
.toValue({'a': 2}),
|
||||
]
|
||||
})
|
||||
.then((_) => injector.get(SampleDescription))
|
||||
|
@ -1,9 +1,31 @@
|
||||
import {afterEach, AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from 'angular2/testing_internal';
|
||||
import {
|
||||
afterEach,
|
||||
AsyncTestCompleter,
|
||||
beforeEach,
|
||||
ddescribe,
|
||||
describe,
|
||||
expect,
|
||||
iit,
|
||||
inject,
|
||||
it,
|
||||
xit,
|
||||
} from 'angular2/testing_internal';
|
||||
|
||||
import {isBlank, isPresent, stringify, Date, DateWrapper} from 'angular2/src/facade/lang';
|
||||
import {PromiseWrapper} from 'angular2/src/facade/async';
|
||||
|
||||
import {Sampler, WebDriverAdapter, Validator, Metric, Reporter, bind, provide, Injector, Options, MeasureValues} from 'benchpress/common';
|
||||
import {
|
||||
Sampler,
|
||||
WebDriverAdapter,
|
||||
Validator,
|
||||
Metric,
|
||||
Reporter,
|
||||
bind,
|
||||
provide,
|
||||
Injector,
|
||||
Options,
|
||||
MeasureValues
|
||||
} from 'benchpress/common';
|
||||
|
||||
export function main() {
|
||||
var EMPTY_EXECUTE = () => {};
|
||||
@ -30,9 +52,13 @@ export function main() {
|
||||
driver = new MockDriverAdapter([]);
|
||||
}
|
||||
var bindings = [
|
||||
Options.DEFAULT_PROVIDERS, Sampler.BINDINGS, provide(Metric, {useValue: metric}),
|
||||
provide(Reporter, {useValue: reporter}), provide(WebDriverAdapter, {useValue: driver}),
|
||||
bind(Options.EXECUTE).toValue(execute), provide(Validator, {useValue: validator}),
|
||||
Options.DEFAULT_PROVIDERS,
|
||||
Sampler.BINDINGS,
|
||||
provide(Metric, {useValue: metric}),
|
||||
provide(Reporter, {useValue: reporter}),
|
||||
provide(WebDriverAdapter, {useValue: driver}),
|
||||
bind(Options.EXECUTE).toValue(execute),
|
||||
provide(Validator, {useValue: validator}),
|
||||
bind(Options.NOW).toValue(() => DateWrapper.fromMillis(time++))
|
||||
];
|
||||
if (isPresent(prepare)) {
|
||||
@ -118,13 +144,12 @@ export function main() {
|
||||
var iterationCount = 1;
|
||||
createSampler({
|
||||
validator: createCountingValidator(2),
|
||||
metric: new MockMetric(
|
||||
[],
|
||||
() => {
|
||||
var result = PromiseWrapper.resolve({'script': scriptTime});
|
||||
scriptTime = 0;
|
||||
return result;
|
||||
}),
|
||||
metric: new MockMetric([],
|
||||
() => {
|
||||
var result = PromiseWrapper.resolve({'script': scriptTime});
|
||||
scriptTime = 0;
|
||||
return result;
|
||||
}),
|
||||
prepare: () => { scriptTime = 1 * iterationCount; },
|
||||
execute: () => {
|
||||
scriptTime = 10 * iterationCount;
|
||||
@ -186,7 +211,9 @@ export function main() {
|
||||
expect(log[0]).toEqual(['reportMeasureValues', mv(0, 1000, {'script': 0})]);
|
||||
expect(log[1]).toEqual(['reportMeasureValues', mv(1, 1001, {'script': 1})]);
|
||||
expect(log[2]).toEqual([
|
||||
'reportSample', [mv(0, 1000, {'script': 0}), mv(1, 1001, {'script': 1})], validSample
|
||||
'reportSample',
|
||||
[mv(0, 1000, {'script': 0}), mv(1, 1001, {'script': 1})],
|
||||
validSample
|
||||
]);
|
||||
|
||||
async.done();
|
||||
|
@ -1,4 +1,13 @@
|
||||
import {describe, ddescribe, it, iit, xit, expect, beforeEach, afterEach} from 'angular2/testing_internal';
|
||||
import {
|
||||
describe,
|
||||
ddescribe,
|
||||
it,
|
||||
iit,
|
||||
xit,
|
||||
expect,
|
||||
beforeEach,
|
||||
afterEach
|
||||
} from 'angular2/testing_internal';
|
||||
|
||||
import {Statistic} from 'benchpress/src/statistic';
|
||||
|
||||
|
@ -1,20 +1,35 @@
|
||||
import {describe, ddescribe, it, iit, xit, expect, beforeEach, afterEach} from 'angular2/testing_internal';
|
||||
import {
|
||||
describe,
|
||||
ddescribe,
|
||||
it,
|
||||
iit,
|
||||
xit,
|
||||
expect,
|
||||
beforeEach,
|
||||
afterEach
|
||||
} from 'angular2/testing_internal';
|
||||
import {Date, DateWrapper} from 'angular2/src/facade/lang';
|
||||
import {ListWrapper} from 'angular2/src/facade/collection';
|
||||
|
||||
import {Validator, RegressionSlopeValidator, Injector, bind, provide, MeasureValues} from 'benchpress/common';
|
||||
import {
|
||||
Validator,
|
||||
RegressionSlopeValidator,
|
||||
Injector,
|
||||
bind,
|
||||
provide,
|
||||
MeasureValues
|
||||
} from 'benchpress/common';
|
||||
|
||||
export function main() {
|
||||
describe('regression slope validator', () => {
|
||||
var validator;
|
||||
|
||||
function createValidator({size, metric}) {
|
||||
validator = Injector
|
||||
.resolveAndCreate([
|
||||
RegressionSlopeValidator.BINDINGS,
|
||||
bind(RegressionSlopeValidator.METRIC).toValue(metric),
|
||||
bind(RegressionSlopeValidator.SAMPLE_SIZE).toValue(size)
|
||||
])
|
||||
validator = Injector.resolveAndCreate([
|
||||
RegressionSlopeValidator.BINDINGS,
|
||||
bind(RegressionSlopeValidator.METRIC).toValue(metric),
|
||||
bind(RegressionSlopeValidator.SAMPLE_SIZE).toValue(size)
|
||||
])
|
||||
.get(RegressionSlopeValidator);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,13 @@
|
||||
import {describe, ddescribe, it, iit, xit, expect, beforeEach, afterEach} from 'angular2/testing_internal';
|
||||
import {
|
||||
describe,
|
||||
ddescribe,
|
||||
it,
|
||||
iit,
|
||||
xit,
|
||||
expect,
|
||||
beforeEach,
|
||||
afterEach
|
||||
} from 'angular2/testing_internal';
|
||||
import {Date, DateWrapper} from 'angular2/src/facade/lang';
|
||||
import {ListWrapper} from 'angular2/src/facade/collection';
|
||||
|
||||
@ -9,10 +18,10 @@ export function main() {
|
||||
var validator;
|
||||
|
||||
function createValidator(size) {
|
||||
validator = Injector
|
||||
.resolveAndCreate(
|
||||
[SizeValidator.BINDINGS, bind(SizeValidator.SAMPLE_SIZE).toValue(size)])
|
||||
.get(SizeValidator);
|
||||
validator =
|
||||
Injector.resolveAndCreate(
|
||||
[SizeValidator.BINDINGS, bind(SizeValidator.SAMPLE_SIZE).toValue(size)])
|
||||
.get(SizeValidator);
|
||||
}
|
||||
|
||||
it('should return sampleSize as description', () => {
|
||||
|
@ -1,4 +1,15 @@
|
||||
import {afterEach, AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from 'angular2/testing_internal';
|
||||
import {
|
||||
afterEach,
|
||||
AsyncTestCompleter,
|
||||
beforeEach,
|
||||
ddescribe,
|
||||
describe,
|
||||
expect,
|
||||
iit,
|
||||
inject,
|
||||
it,
|
||||
xit,
|
||||
} from 'angular2/testing_internal';
|
||||
|
||||
import {isPresent, StringWrapper} from 'angular2/src/facade/lang';
|
||||
import {PromiseWrapper} from 'angular2/src/facade/async';
|
||||
@ -8,11 +19,11 @@ import {WebDriverExtension, bind, provide, Injector, Options} from 'benchpress/c
|
||||
export function main() {
|
||||
function createExtension(ids: any[], caps) {
|
||||
return PromiseWrapper.wrap(() => {
|
||||
return Injector
|
||||
.resolveAndCreate([
|
||||
ids.map(id => provide(id, {useValue: new MockExtension(id)})),
|
||||
bind(Options.CAPABILITIES).toValue(caps), WebDriverExtension.bindTo(ids)
|
||||
])
|
||||
return Injector.resolveAndCreate([
|
||||
ids.map(id => provide(id, {useValue: new MockExtension(id)})),
|
||||
bind(Options.CAPABILITIES).toValue(caps),
|
||||
WebDriverExtension.bindTo(ids)
|
||||
])
|
||||
.get(WebDriverExtension);
|
||||
});
|
||||
}
|
||||
@ -21,10 +32,11 @@ export function main() {
|
||||
|
||||
it('should bind the extension that matches the capabilities',
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
createExtension(['m1', 'm2', 'm3'], {'browser': 'm2'}).then((m) => {
|
||||
expect(m.id).toEqual('m2');
|
||||
async.done();
|
||||
});
|
||||
createExtension(['m1', 'm2', 'm3'], {'browser': 'm2'})
|
||||
.then((m) => {
|
||||
expect(m.id).toEqual('m2');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should throw if there is no match', inject([AsyncTestCompleter], (async) => {
|
||||
|
@ -1,9 +1,28 @@
|
||||
import {afterEach, AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from 'angular2/testing_internal';
|
||||
import {
|
||||
afterEach,
|
||||
AsyncTestCompleter,
|
||||
beforeEach,
|
||||
ddescribe,
|
||||
describe,
|
||||
expect,
|
||||
iit,
|
||||
inject,
|
||||
it,
|
||||
xit,
|
||||
} from 'angular2/testing_internal';
|
||||
|
||||
import {PromiseWrapper} from 'angular2/src/facade/async';
|
||||
import {Json, isBlank} from 'angular2/src/facade/lang';
|
||||
|
||||
import {WebDriverExtension, ChromeDriverExtension, WebDriverAdapter, Injector, bind, provide, Options} from 'benchpress/common';
|
||||
import {
|
||||
WebDriverExtension,
|
||||
ChromeDriverExtension,
|
||||
WebDriverAdapter,
|
||||
Injector,
|
||||
bind,
|
||||
provide,
|
||||
Options
|
||||
} from 'benchpress/common';
|
||||
|
||||
import {TraceEventFactory} from '../trace_event_factory';
|
||||
|
||||
@ -29,9 +48,8 @@ export function main() {
|
||||
var benchmarkEvents = new TraceEventFactory('benchmark', 'pid0');
|
||||
var normEvents = new TraceEventFactory('timeline', 'pid0');
|
||||
|
||||
function createExtension(
|
||||
perfRecords = null, userAgent = null,
|
||||
messageMethod = 'Tracing.dataCollected'): WebDriverExtension {
|
||||
function createExtension(perfRecords = null, userAgent = null,
|
||||
messageMethod = 'Tracing.dataCollected'): WebDriverExtension {
|
||||
if (isBlank(perfRecords)) {
|
||||
perfRecords = [];
|
||||
}
|
||||
@ -39,13 +57,12 @@ export function main() {
|
||||
userAgent = CHROME44_USER_AGENT;
|
||||
}
|
||||
log = [];
|
||||
extension = Injector
|
||||
.resolveAndCreate([
|
||||
ChromeDriverExtension.BINDINGS,
|
||||
bind(WebDriverAdapter)
|
||||
.toValue(new MockDriverAdapter(log, perfRecords, messageMethod)),
|
||||
bind(Options.USER_AGENT).toValue(userAgent)
|
||||
])
|
||||
extension = Injector.resolveAndCreate([
|
||||
ChromeDriverExtension.BINDINGS,
|
||||
bind(WebDriverAdapter)
|
||||
.toValue(new MockDriverAdapter(log, perfRecords, messageMethod)),
|
||||
bind(Options.USER_AGENT).toValue(userAgent)
|
||||
])
|
||||
.get(ChromeDriverExtension);
|
||||
return extension;
|
||||
}
|
||||
@ -58,26 +75,32 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should mark the timeline via console.time()', inject([AsyncTestCompleter], (async) => {
|
||||
createExtension().timeBegin('someName').then((_) => {
|
||||
expect(log).toEqual([['executeScript', `console.time('someName');`]]);
|
||||
async.done();
|
||||
});
|
||||
createExtension()
|
||||
.timeBegin('someName')
|
||||
.then((_) => {
|
||||
expect(log).toEqual([['executeScript', `console.time('someName');`]]);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should mark the timeline via console.timeEnd()', inject([AsyncTestCompleter], (async) => {
|
||||
createExtension().timeEnd('someName', null).then((_) => {
|
||||
expect(log).toEqual([['executeScript', `console.timeEnd('someName');`]]);
|
||||
async.done();
|
||||
});
|
||||
createExtension()
|
||||
.timeEnd('someName', null)
|
||||
.then((_) => {
|
||||
expect(log).toEqual([['executeScript', `console.timeEnd('someName');`]]);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should mark the timeline via console.time() and console.timeEnd()',
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
createExtension().timeEnd('name1', 'name2').then((_) => {
|
||||
expect(log).toEqual(
|
||||
[['executeScript', `console.timeEnd('name1');console.time('name2');`]]);
|
||||
async.done();
|
||||
});
|
||||
createExtension()
|
||||
.timeEnd('name1', 'name2')
|
||||
.then((_) => {
|
||||
expect(log)
|
||||
.toEqual([['executeScript', `console.timeEnd('name1');console.time('name2');`]]);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
describe('readPerfLog Chrome44', () => {
|
||||
@ -183,8 +206,10 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should ignore FunctionCalls from webdriver', inject([AsyncTestCompleter], (async) => {
|
||||
createExtension([chromeTimelineEvents.start(
|
||||
'FunctionCall', 0, {'data': {'scriptName': 'InjectedScript'}})])
|
||||
createExtension([
|
||||
chromeTimelineEvents.start('FunctionCall', 0,
|
||||
{'data': {'scriptName': 'InjectedScript'}})
|
||||
])
|
||||
.readPerfLog()
|
||||
.then((events) => {
|
||||
expect(events).toEqual([]);
|
||||
@ -198,9 +223,8 @@ export function main() {
|
||||
describe('readPerfLog Chrome45', () => {
|
||||
it('should normalize times to ms and forward ph and pid event properties',
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
createExtension(
|
||||
[chromeTimelineV8Events.complete('FunctionCall', 1100, 5500, null)],
|
||||
CHROME45_USER_AGENT)
|
||||
createExtension([chromeTimelineV8Events.complete('FunctionCall', 1100, 5500, null)],
|
||||
CHROME45_USER_AGENT)
|
||||
.readPerfLog()
|
||||
.then((events) => {
|
||||
expect(events).toEqual([
|
||||
@ -213,12 +237,14 @@ export function main() {
|
||||
it('should normalize "tdur" to "dur"', inject([AsyncTestCompleter], (async) => {
|
||||
var event = chromeTimelineV8Events.create('X', 'FunctionCall', 1100, null);
|
||||
event['tdur'] = 5500;
|
||||
createExtension([event], CHROME45_USER_AGENT).readPerfLog().then((events) => {
|
||||
expect(events).toEqual([
|
||||
normEvents.complete('script', 1.1, 5.5, null),
|
||||
]);
|
||||
async.done();
|
||||
});
|
||||
createExtension([event], CHROME45_USER_AGENT)
|
||||
.readPerfLog()
|
||||
.then((events) => {
|
||||
expect(events).toEqual([
|
||||
normEvents.complete('script', 1.1, 5.5, null),
|
||||
]);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should report FunctionCall events as "script"', inject([AsyncTestCompleter], (async) => {
|
||||
@ -244,8 +270,8 @@ export function main() {
|
||||
expect(events.length).toEqual(2);
|
||||
expect(events[0]).toEqual(
|
||||
normEvents.start('gc', 1.0, {'usedHeapSize': 1000, 'majorGc': false}));
|
||||
expect(events[1]).toEqual(
|
||||
normEvents.end('gc', 2.0, {'usedHeapSize': 0, 'majorGc': false}));
|
||||
expect(events[1])
|
||||
.toEqual(normEvents.end('gc', 2.0, {'usedHeapSize': 0, 'majorGc': false}));
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@ -260,10 +286,10 @@ export function main() {
|
||||
.readPerfLog()
|
||||
.then((events) => {
|
||||
expect(events.length).toEqual(2);
|
||||
expect(events[0]).toEqual(
|
||||
normEvents.start('gc', 1.0, {'usedHeapSize': 1000, 'majorGc': true}));
|
||||
expect(events[1]).toEqual(
|
||||
normEvents.end('gc', 2.0, {'usedHeapSize': 0, 'majorGc': true}));
|
||||
expect(events[0])
|
||||
.toEqual(normEvents.start('gc', 1.0, {'usedHeapSize': 1000, 'majorGc': true}));
|
||||
expect(events[1])
|
||||
.toEqual(normEvents.end('gc', 2.0, {'usedHeapSize': 0, 'majorGc': true}));
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@ -307,8 +333,10 @@ export function main() {
|
||||
|
||||
|
||||
it('should ignore FunctionCalls from webdriver', inject([AsyncTestCompleter], (async) => {
|
||||
createExtension([chromeTimelineV8Events.start(
|
||||
'FunctionCall', 0, {'data': {'scriptName': 'InjectedScript'}})])
|
||||
createExtension([
|
||||
chromeTimelineV8Events.start('FunctionCall', 0,
|
||||
{'data': {'scriptName': 'InjectedScript'}})
|
||||
])
|
||||
.readPerfLog()
|
||||
.then((events) => {
|
||||
expect(events).toEqual([]);
|
||||
@ -328,8 +356,8 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should report navigationStart', inject([AsyncTestCompleter], (async) => {
|
||||
createExtension(
|
||||
[chromeBlinkUserTimingEvents.start('navigationStart', 1234)], CHROME45_USER_AGENT)
|
||||
createExtension([chromeBlinkUserTimingEvents.start('navigationStart', 1234)],
|
||||
CHROME45_USER_AGENT)
|
||||
.readPerfLog()
|
||||
.then((events) => {
|
||||
expect(events).toEqual([normEvents.start('navigationStart', 1.234)]);
|
||||
@ -339,8 +367,10 @@ export function main() {
|
||||
|
||||
it('should report receivedData', inject([AsyncTestCompleter], (async) => {
|
||||
createExtension(
|
||||
[chrome45TimelineEvents.instant(
|
||||
'ResourceReceivedData', 1234, {'data': {'encodedDataLength': 987}})],
|
||||
[
|
||||
chrome45TimelineEvents.instant('ResourceReceivedData', 1234,
|
||||
{'data': {'encodedDataLength': 987}})
|
||||
],
|
||||
CHROME45_USER_AGENT)
|
||||
.readPerfLog()
|
||||
.then((events) => {
|
||||
@ -352,14 +382,18 @@ export function main() {
|
||||
|
||||
it('should report sendRequest', inject([AsyncTestCompleter], (async) => {
|
||||
createExtension(
|
||||
[chrome45TimelineEvents.instant(
|
||||
'ResourceSendRequest', 1234,
|
||||
{'data': {'url': 'http://here', 'requestMethod': 'GET'}})],
|
||||
[
|
||||
chrome45TimelineEvents.instant(
|
||||
'ResourceSendRequest', 1234,
|
||||
{'data': {'url': 'http://here', 'requestMethod': 'GET'}})
|
||||
],
|
||||
CHROME45_USER_AGENT)
|
||||
.readPerfLog()
|
||||
.then((events) => {
|
||||
expect(events).toEqual([normEvents.instant(
|
||||
'sendRequest', 1.234, {'url': 'http://here', 'method': 'GET'})]);
|
||||
expect(events).toEqual([
|
||||
normEvents.instant('sendRequest', 1.234,
|
||||
{'url': 'http://here', 'method': 'GET'})
|
||||
]);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@ -400,9 +434,10 @@ export function main() {
|
||||
describe('frame metrics', () => {
|
||||
it('should report ImplThreadRenderingStats as frame event',
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
createExtension([benchmarkEvents.instant(
|
||||
'BenchmarkInstrumentation::ImplThreadRenderingStats', 1100,
|
||||
{'data': {'frame_count': 1}})])
|
||||
createExtension([
|
||||
benchmarkEvents.instant('BenchmarkInstrumentation::ImplThreadRenderingStats', 1100,
|
||||
{'data': {'frame_count': 1}})
|
||||
])
|
||||
.readPerfLog()
|
||||
.then((events) => {
|
||||
expect(events).toEqual([
|
||||
@ -414,9 +449,10 @@ export function main() {
|
||||
|
||||
it('should not report ImplThreadRenderingStats with zero frames',
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
createExtension([benchmarkEvents.instant(
|
||||
'BenchmarkInstrumentation::ImplThreadRenderingStats', 1100,
|
||||
{'data': {'frame_count': 0}})])
|
||||
createExtension([
|
||||
benchmarkEvents.instant('BenchmarkInstrumentation::ImplThreadRenderingStats', 1100,
|
||||
{'data': {'frame_count': 0}})
|
||||
])
|
||||
.readPerfLog()
|
||||
.then((events) => {
|
||||
expect(events).toEqual([]);
|
||||
@ -428,14 +464,12 @@ export function main() {
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
PromiseWrapper.catchError(
|
||||
createExtension([
|
||||
benchmarkEvents.instant(
|
||||
'BenchmarkInstrumentation::ImplThreadRenderingStats', 1100,
|
||||
{'data': {'frame_count': 2}})
|
||||
benchmarkEvents.instant('BenchmarkInstrumentation::ImplThreadRenderingStats',
|
||||
1100, {'data': {'frame_count': 2}})
|
||||
]).readPerfLog(),
|
||||
(err): any => {
|
||||
expect(() => {
|
||||
throw err;
|
||||
}).toThrowError('multi-frame render stats not supported');
|
||||
expect(() => { throw err; })
|
||||
.toThrowError('multi-frame render stats not supported');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@ -469,9 +503,8 @@ export function main() {
|
||||
CHROME45_USER_AGENT, 'Tracing.bufferUsage')
|
||||
.readPerfLog(),
|
||||
(err): any => {
|
||||
expect(() => {
|
||||
throw err;
|
||||
}).toThrowError('The DevTools trace buffer filled during the test!');
|
||||
expect(() => { throw err; })
|
||||
.toThrowError('The DevTools trace buffer filled during the test!');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
@ -1,9 +1,27 @@
|
||||
import {afterEach, AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from 'angular2/testing_internal';
|
||||
import {
|
||||
afterEach,
|
||||
AsyncTestCompleter,
|
||||
beforeEach,
|
||||
ddescribe,
|
||||
describe,
|
||||
expect,
|
||||
iit,
|
||||
inject,
|
||||
it,
|
||||
xit,
|
||||
} from 'angular2/testing_internal';
|
||||
|
||||
import {PromiseWrapper} from 'angular2/src/facade/async';
|
||||
import {Json, isBlank, isPresent} from 'angular2/src/facade/lang';
|
||||
|
||||
import {WebDriverExtension, IOsDriverExtension, WebDriverAdapter, Injector, bind, provide} from 'benchpress/common';
|
||||
import {
|
||||
WebDriverExtension,
|
||||
IOsDriverExtension,
|
||||
WebDriverAdapter,
|
||||
Injector,
|
||||
bind,
|
||||
provide
|
||||
} from 'benchpress/common';
|
||||
|
||||
import {TraceEventFactory} from '../trace_event_factory';
|
||||
|
||||
@ -20,11 +38,10 @@ export function main() {
|
||||
}
|
||||
log = [];
|
||||
extension =
|
||||
Injector
|
||||
.resolveAndCreate([
|
||||
IOsDriverExtension.BINDINGS,
|
||||
provide(WebDriverAdapter, {useValue: new MockDriverAdapter(log, perfRecords)})
|
||||
])
|
||||
Injector.resolveAndCreate([
|
||||
IOsDriverExtension.BINDINGS,
|
||||
provide(WebDriverAdapter, {useValue: new MockDriverAdapter(log, perfRecords)})
|
||||
])
|
||||
.get(IOsDriverExtension);
|
||||
return extension;
|
||||
}
|
||||
@ -34,26 +51,32 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should mark the timeline via console.time()', inject([AsyncTestCompleter], (async) => {
|
||||
createExtension().timeBegin('someName').then((_) => {
|
||||
expect(log).toEqual([['executeScript', `console.time('someName');`]]);
|
||||
async.done();
|
||||
});
|
||||
createExtension()
|
||||
.timeBegin('someName')
|
||||
.then((_) => {
|
||||
expect(log).toEqual([['executeScript', `console.time('someName');`]]);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should mark the timeline via console.timeEnd()', inject([AsyncTestCompleter], (async) => {
|
||||
createExtension().timeEnd('someName', null).then((_) => {
|
||||
expect(log).toEqual([['executeScript', `console.timeEnd('someName');`]]);
|
||||
async.done();
|
||||
});
|
||||
createExtension()
|
||||
.timeEnd('someName', null)
|
||||
.then((_) => {
|
||||
expect(log).toEqual([['executeScript', `console.timeEnd('someName');`]]);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should mark the timeline via console.time() and console.timeEnd()',
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
createExtension().timeEnd('name1', 'name2').then((_) => {
|
||||
expect(log).toEqual(
|
||||
[['executeScript', `console.timeEnd('name1');console.time('name2');`]]);
|
||||
async.done();
|
||||
});
|
||||
createExtension()
|
||||
.timeEnd('name1', 'name2')
|
||||
.then((_) => {
|
||||
expect(log)
|
||||
.toEqual([['executeScript', `console.timeEnd('name1');console.time('name2');`]]);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
describe('readPerfLog', () => {
|
||||
@ -70,31 +93,40 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should report FunctionCall records as "script"', inject([AsyncTestCompleter], (async) => {
|
||||
createExtension([durationRecord('FunctionCall', 1, 5)]).readPerfLog().then((events) => {
|
||||
expect(events).toEqual([normEvents.start('script', 1), normEvents.end('script', 5)]);
|
||||
async.done();
|
||||
});
|
||||
createExtension([durationRecord('FunctionCall', 1, 5)])
|
||||
.readPerfLog()
|
||||
.then((events) => {
|
||||
expect(events)
|
||||
.toEqual([normEvents.start('script', 1), normEvents.end('script', 5)]);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should ignore FunctionCalls from webdriver', inject([AsyncTestCompleter], (async) => {
|
||||
createExtension([internalScriptRecord(1, 5)]).readPerfLog().then((events) => {
|
||||
expect(events).toEqual([]);
|
||||
async.done();
|
||||
});
|
||||
createExtension([internalScriptRecord(1, 5)])
|
||||
.readPerfLog()
|
||||
.then((events) => {
|
||||
expect(events).toEqual([]);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should report begin time', inject([AsyncTestCompleter], (async) => {
|
||||
createExtension([timeBeginRecord('someName', 12)]).readPerfLog().then((events) => {
|
||||
expect(events).toEqual([normEvents.markStart('someName', 12)]);
|
||||
async.done();
|
||||
});
|
||||
createExtension([timeBeginRecord('someName', 12)])
|
||||
.readPerfLog()
|
||||
.then((events) => {
|
||||
expect(events).toEqual([normEvents.markStart('someName', 12)]);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should report end timestamps', inject([AsyncTestCompleter], (async) => {
|
||||
createExtension([timeEndRecord('someName', 12)]).readPerfLog().then((events) => {
|
||||
expect(events).toEqual([normEvents.markEnd('someName', 12)]);
|
||||
async.done();
|
||||
});
|
||||
createExtension([timeEndRecord('someName', 12)])
|
||||
.readPerfLog()
|
||||
.then((events) => {
|
||||
expect(events).toEqual([normEvents.markEnd('someName', 12)]);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
['RecalculateStyles', 'Layout', 'UpdateLayerTree', 'Paint', 'Rasterize', 'CompositeLayers']
|
||||
@ -118,7 +150,8 @@ export function main() {
|
||||
.readPerfLog()
|
||||
.then((events) => {
|
||||
expect(events).toEqual([
|
||||
normEvents.start('script', 1), normEvents.markStart('someName', 2),
|
||||
normEvents.start('script', 1),
|
||||
normEvents.markStart('someName', 2),
|
||||
normEvents.end('script', 5)
|
||||
]);
|
||||
async.done();
|
||||
|
Reference in New Issue
Block a user