refactor(chore): Replace all 'bindings' with 'providers'
BREAKING CHANGE Deprecated `bindings:` and `viewBindings:` are replaced with `providers:` and `viewProviders:` Closes #7687
This commit is contained in:

committed by
Misko Hevery

parent
49fb7ef421
commit
0795dd307b
@ -173,7 +173,7 @@ To collect these metrics, you need to execute `console.time('frameCapture')` and
|
||||
|
||||
In addition to that, one extra binding needs to be passed to benchpress in tests that want to collect these metrics:
|
||||
|
||||
benchpress.sample(bindings: [bp.bind(bp.Options.CAPTURE_FRAMES).toValue(true)], ... )
|
||||
benchpress.sample(providers: [bp.bind(bp.Options.CAPTURE_FRAMES).toValue(true)], ... )
|
||||
|
||||
# Requests Metrics
|
||||
|
||||
@ -182,9 +182,9 @@ Benchpress can also record the number of requests sent and count the received "e
|
||||
- `receivedData`: number of bytes received since the last navigation start
|
||||
- `requestCount`: number of requests sent since the last navigation start
|
||||
|
||||
To collect these metrics, you need the following corresponding extra bindings:
|
||||
To collect these metrics, you need the following corresponding extra providers:
|
||||
|
||||
benchpress.sample(bindings: [
|
||||
benchpress.sample(providers: [
|
||||
bp.bind(bp.Options.RECEIVED_DATA).toValue(true),
|
||||
bp.bind(bp.Options.REQUEST_COUNT).toValue(true)
|
||||
], ... )
|
||||
|
@ -20,7 +20,7 @@ import {Options} from '../common_options';
|
||||
*/
|
||||
export class PerflogMetric extends Metric {
|
||||
// TODO(tbosch): use static values when our transpiler supports them
|
||||
static get BINDINGS(): Provider[] { return _PROVIDERS; }
|
||||
static get PROVIDERS(): Provider[] { return _PROVIDERS; }
|
||||
// TODO(tbosch): use static values when our transpiler supports them
|
||||
static get SET_TIMEOUT(): OpaqueToken { return _SET_TIMEOUT; }
|
||||
|
||||
|
@ -18,7 +18,7 @@ export class ConsoleReporter extends Reporter {
|
||||
// TODO(tbosch): use static values when our transpiler supports them
|
||||
static get COLUMN_WIDTH(): OpaqueToken { return _COLUMN_WIDTH; }
|
||||
// TODO(tbosch): use static values when our transpiler supports them
|
||||
static get BINDINGS(): Provider[] { return _PROVIDERS; }
|
||||
static get PROVIDERS(): Provider[] { return _PROVIDERS; }
|
||||
|
||||
|
||||
static _lpad(value, columnWidth, fill = ' ') {
|
||||
|
@ -15,7 +15,7 @@ export class JsonFileReporter extends Reporter {
|
||||
// TODO(tbosch): use static values when our transpiler supports them
|
||||
static get PATH(): OpaqueToken { return _PATH; }
|
||||
// TODO(tbosch): use static values when our transpiler supports them
|
||||
static get BINDINGS(): Provider[] { return _PROVIDERS; }
|
||||
static get PROVIDERS(): Provider[] { return _PROVIDERS; }
|
||||
|
||||
_writeFile: Function;
|
||||
_path: string;
|
||||
|
@ -25,34 +25,34 @@ import {Options} from './common_options';
|
||||
* It provides defaults, creates the injector and calls the sampler.
|
||||
*/
|
||||
export class Runner {
|
||||
private _defaultBindings: Provider[];
|
||||
constructor(defaultBindings: Provider[] = null) {
|
||||
if (isBlank(defaultBindings)) {
|
||||
defaultBindings = [];
|
||||
private _defaultProviders: Provider[];
|
||||
constructor(defaultProviders: Provider[] = null) {
|
||||
if (isBlank(defaultProviders)) {
|
||||
defaultProviders = [];
|
||||
}
|
||||
this._defaultBindings = defaultBindings;
|
||||
this._defaultProviders = defaultProviders;
|
||||
}
|
||||
|
||||
sample({id, execute, prepare, microMetrics, bindings}:
|
||||
{id: string, execute?: any, prepare?: any, microMetrics?: any, bindings?: any}):
|
||||
sample({id, execute, prepare, microMetrics, providers}:
|
||||
{id: string, execute?: any, prepare?: any, microMetrics?: any, providers?: any}):
|
||||
Promise<SampleState> {
|
||||
var sampleBindings = [
|
||||
var sampleProviders = [
|
||||
_DEFAULT_PROVIDERS,
|
||||
this._defaultBindings,
|
||||
this._defaultProviders,
|
||||
bind(Options.SAMPLE_ID).toValue(id),
|
||||
bind(Options.EXECUTE).toValue(execute)
|
||||
];
|
||||
if (isPresent(prepare)) {
|
||||
sampleBindings.push(bind(Options.PREPARE).toValue(prepare));
|
||||
sampleProviders.push(bind(Options.PREPARE).toValue(prepare));
|
||||
}
|
||||
if (isPresent(microMetrics)) {
|
||||
sampleBindings.push(bind(Options.MICRO_METRICS).toValue(microMetrics));
|
||||
sampleProviders.push(bind(Options.MICRO_METRICS).toValue(microMetrics));
|
||||
}
|
||||
if (isPresent(bindings)) {
|
||||
sampleBindings.push(bindings);
|
||||
if (isPresent(providers)) {
|
||||
sampleProviders.push(providers);
|
||||
}
|
||||
|
||||
var inj = ReflectiveInjector.resolveAndCreate(sampleBindings);
|
||||
var inj = ReflectiveInjector.resolveAndCreate(sampleProviders);
|
||||
var adapter = inj.get(WebDriverAdapter);
|
||||
|
||||
return PromiseWrapper
|
||||
@ -67,7 +67,7 @@ export class Runner {
|
||||
// TODO vsavkin consider changing it when toAsyncFactory is added back or when child
|
||||
// injectors are handled better.
|
||||
var injector = ReflectiveInjector.resolveAndCreate([
|
||||
sampleBindings,
|
||||
sampleProviders,
|
||||
bind(Options.CAPABILITIES).toValue(capabilities),
|
||||
bind(Options.USER_AGENT).toValue(userAgent),
|
||||
provide(WebDriverAdapter, {useValue: adapter})
|
||||
@ -81,15 +81,15 @@ export class Runner {
|
||||
|
||||
var _DEFAULT_PROVIDERS = [
|
||||
Options.DEFAULT_PROVIDERS,
|
||||
Sampler.BINDINGS,
|
||||
ConsoleReporter.BINDINGS,
|
||||
RegressionSlopeValidator.BINDINGS,
|
||||
SizeValidator.BINDINGS,
|
||||
ChromeDriverExtension.BINDINGS,
|
||||
FirefoxDriverExtension.BINDINGS,
|
||||
IOsDriverExtension.BINDINGS,
|
||||
PerflogMetric.BINDINGS,
|
||||
SampleDescription.BINDINGS,
|
||||
Sampler.PROVIDERS,
|
||||
ConsoleReporter.PROVIDERS,
|
||||
RegressionSlopeValidator.PROVIDERS,
|
||||
SizeValidator.PROVIDERS,
|
||||
ChromeDriverExtension.PROVIDERS,
|
||||
FirefoxDriverExtension.PROVIDERS,
|
||||
IOsDriverExtension.PROVIDERS,
|
||||
PerflogMetric.PROVIDERS,
|
||||
SampleDescription.PROVIDERS,
|
||||
MultiReporter.createBindings([ConsoleReporter]),
|
||||
MultiMetric.createBindings([PerflogMetric]),
|
||||
|
||||
|
@ -9,7 +9,7 @@ import {Options} from './common_options';
|
||||
*/
|
||||
export class SampleDescription {
|
||||
// TODO(tbosch): use static values when our transpiler supports them
|
||||
static get BINDINGS(): Provider[] { return _PROVIDERS; }
|
||||
static get PROVIDERS(): Provider[] { return _PROVIDERS; }
|
||||
description: {[key: string]: any};
|
||||
|
||||
constructor(public id: string, descriptions: Array<{[key: string]: any}>,
|
||||
|
@ -20,7 +20,7 @@ import {MeasureValues} from './measure_values';
|
||||
*/
|
||||
export class Sampler {
|
||||
// TODO(tbosch): use static values when our transpiler supports them
|
||||
static get BINDINGS(): Provider[] { return _PROVIDERS; }
|
||||
static get PROVIDERS(): Provider[] { return _PROVIDERS; }
|
||||
|
||||
_driver: WebDriverAdapter;
|
||||
_metric: Metric;
|
||||
|
@ -15,7 +15,7 @@ export class RegressionSlopeValidator extends Validator {
|
||||
// TODO(tbosch): use static values when our transpiler supports them
|
||||
static get METRIC(): OpaqueToken { return _METRIC; }
|
||||
// TODO(tbosch): use static values when our transpiler supports them
|
||||
static get BINDINGS(): Provider[] { return _PROVIDERS; }
|
||||
static get PROVIDERS(): Provider[] { return _PROVIDERS; }
|
||||
|
||||
_sampleSize: number;
|
||||
_metric: string;
|
||||
|
@ -9,7 +9,7 @@ import {MeasureValues} from '../measure_values';
|
||||
*/
|
||||
export class SizeValidator extends Validator {
|
||||
// TODO(tbosch): use static values when our transpiler supports them
|
||||
static get BINDINGS(): Provider[] { return _PROVIDERS; }
|
||||
static get PROVIDERS(): Provider[] { return _PROVIDERS; }
|
||||
// TODO(tbosch): use static values when our transpiler supports them
|
||||
static get SAMPLE_SIZE() { return _SAMPLE_SIZE; }
|
||||
|
||||
|
@ -23,7 +23,7 @@ import {Options} from '../common_options';
|
||||
*/
|
||||
export class ChromeDriverExtension extends WebDriverExtension {
|
||||
// TODO(tbosch): use static values when our transpiler supports them
|
||||
static get BINDINGS(): Provider[] { return _PROVIDERS; }
|
||||
static get PROVIDERS(): Provider[] { return _PROVIDERS; }
|
||||
|
||||
private _majorChromeVersion: number;
|
||||
|
||||
|
@ -4,7 +4,7 @@ import {WebDriverExtension, PerfLogFeatures} from '../web_driver_extension';
|
||||
import {WebDriverAdapter} from '../web_driver_adapter';
|
||||
|
||||
export class FirefoxDriverExtension extends WebDriverExtension {
|
||||
static get BINDINGS(): Provider[] { return _PROVIDERS; }
|
||||
static get PROVIDERS(): Provider[] { return _PROVIDERS; }
|
||||
|
||||
private _profilerStarted: boolean;
|
||||
|
||||
|
@ -7,7 +7,7 @@ import {WebDriverAdapter} from '../web_driver_adapter';
|
||||
|
||||
export class IOsDriverExtension extends WebDriverExtension {
|
||||
// TODO(tbosch): use static values when our transpiler supports them
|
||||
static get BINDINGS(): Provider[] { return _PROVIDERS; }
|
||||
static get PROVIDERS(): Provider[] { return _PROVIDERS; }
|
||||
|
||||
constructor(private _driver: WebDriverAdapter) { super(); }
|
||||
|
||||
|
@ -25,7 +25,7 @@ describe('deep tree baseline', function() {
|
||||
id: 'baseline',
|
||||
execute: function() { $('button')
|
||||
.click(); },
|
||||
bindings: [benchpress.bind(benchpress.Options.SAMPLE_DESCRIPTION).toValue({depth: 9})]
|
||||
providers: [benchpress.bind(benchpress.Options.SAMPLE_DESCRIPTION).toValue({depth: 9})]
|
||||
})
|
||||
.then(done, done.fail);
|
||||
});
|
||||
|
@ -48,9 +48,9 @@ export function main() {
|
||||
if (isBlank(microMetrics)) {
|
||||
microMetrics = StringMapWrapper.create();
|
||||
}
|
||||
var bindings = [
|
||||
var providers = [
|
||||
Options.DEFAULT_PROVIDERS,
|
||||
PerflogMetric.BINDINGS,
|
||||
PerflogMetric.PROVIDERS,
|
||||
bind(Options.MICRO_METRICS).toValue(microMetrics),
|
||||
bind(PerflogMetric.SET_TIMEOUT)
|
||||
.toValue((fn, millis) => {
|
||||
@ -61,18 +61,18 @@ export function main() {
|
||||
.toValue(new MockDriverExtension(perfLogs, commandLog, perfLogFeatures))
|
||||
];
|
||||
if (isPresent(forceGc)) {
|
||||
bindings.push(bind(Options.FORCE_GC).toValue(forceGc));
|
||||
providers.push(bind(Options.FORCE_GC).toValue(forceGc));
|
||||
}
|
||||
if (isPresent(captureFrames)) {
|
||||
bindings.push(bind(Options.CAPTURE_FRAMES).toValue(captureFrames));
|
||||
providers.push(bind(Options.CAPTURE_FRAMES).toValue(captureFrames));
|
||||
}
|
||||
if (isPresent(receivedData)) {
|
||||
bindings.push(bind(Options.RECEIVED_DATA).toValue(receivedData));
|
||||
providers.push(bind(Options.RECEIVED_DATA).toValue(receivedData));
|
||||
}
|
||||
if (isPresent(requestCount)) {
|
||||
bindings.push(bind(Options.REQUEST_COUNT).toValue(requestCount));
|
||||
providers.push(bind(Options.REQUEST_COUNT).toValue(requestCount));
|
||||
}
|
||||
return ReflectiveInjector.resolveAndCreate(bindings).get(PerflogMetric);
|
||||
return ReflectiveInjector.resolveAndCreate(providers).get(PerflogMetric);
|
||||
}
|
||||
|
||||
describe('perflog metric', () => {
|
||||
|
@ -37,7 +37,7 @@ export function main() {
|
||||
sampleId = 'null';
|
||||
}
|
||||
var bindings = [
|
||||
ConsoleReporter.BINDINGS,
|
||||
ConsoleReporter.PROVIDERS,
|
||||
provide(SampleDescription,
|
||||
{useValue: new SampleDescription(sampleId, descriptions, metrics)}),
|
||||
bind(ConsoleReporter.PRINT).toValue((line) => log.push(line))
|
||||
|
@ -32,7 +32,7 @@ export function main() {
|
||||
|
||||
function createReporter({sampleId, descriptions, metrics, path}) {
|
||||
var bindings = [
|
||||
JsonFileReporter.BINDINGS,
|
||||
JsonFileReporter.PROVIDERS,
|
||||
provide(SampleDescription,
|
||||
{useValue: new SampleDescription(sampleId, descriptions, metrics)}),
|
||||
bind(JsonFileReporter.PATH).toValue(path),
|
||||
|
@ -63,7 +63,7 @@ export function main() {
|
||||
|
||||
it('should merge SampleDescription.description', inject([AsyncTestCompleter], (async) => {
|
||||
createRunner([bind(Options.DEFAULT_DESCRIPTION).toValue({'a': 1})])
|
||||
.sample({id: 'someId', bindings: [bind(Options.SAMPLE_DESCRIPTION).toValue({'b': 2})]})
|
||||
.sample({id: 'someId', providers: [bind(Options.SAMPLE_DESCRIPTION).toValue({'b': 2})]})
|
||||
.then((_) => injector.get(SampleDescription))
|
||||
.then((desc) => {
|
||||
expect(desc.description)
|
||||
@ -121,7 +121,7 @@ export function main() {
|
||||
])
|
||||
.sample({
|
||||
id: 'someId',
|
||||
bindings: [
|
||||
providers: [
|
||||
bind(Options.DEFAULT_DESCRIPTION)
|
||||
.toValue({'a': 2}),
|
||||
]
|
||||
|
@ -51,9 +51,9 @@ export function main() {
|
||||
if (isBlank(driver)) {
|
||||
driver = new MockDriverAdapter([]);
|
||||
}
|
||||
var bindings = [
|
||||
var providers = [
|
||||
Options.DEFAULT_PROVIDERS,
|
||||
Sampler.BINDINGS,
|
||||
Sampler.PROVIDERS,
|
||||
provide(Metric, {useValue: metric}),
|
||||
provide(Reporter, {useValue: reporter}),
|
||||
provide(WebDriverAdapter, {useValue: driver}),
|
||||
@ -62,10 +62,10 @@ export function main() {
|
||||
bind(Options.NOW).toValue(() => DateWrapper.fromMillis(time++))
|
||||
];
|
||||
if (isPresent(prepare)) {
|
||||
bindings.push(bind(Options.PREPARE).toValue(prepare));
|
||||
providers.push(bind(Options.PREPARE).toValue(prepare));
|
||||
}
|
||||
|
||||
sampler = ReflectiveInjector.resolveAndCreate(bindings).get(Sampler);
|
||||
sampler = ReflectiveInjector.resolveAndCreate(providers).get(Sampler);
|
||||
}
|
||||
|
||||
it('should call the prepare and execute callbacks using WebDriverAdapter.waitFor',
|
||||
|
@ -26,9 +26,9 @@ export function main() {
|
||||
|
||||
function createValidator({size, metric}) {
|
||||
validator = ReflectiveInjector.resolveAndCreate([
|
||||
RegressionSlopeValidator.BINDINGS,
|
||||
bind(RegressionSlopeValidator.METRIC).toValue(metric),
|
||||
bind(RegressionSlopeValidator.SAMPLE_SIZE).toValue(size)
|
||||
RegressionSlopeValidator.PROVIDERS,
|
||||
provide(RegressionSlopeValidator.METRIC).toValue(metric),
|
||||
provide(RegressionSlopeValidator.SAMPLE_SIZE).toValue(size)
|
||||
])
|
||||
.get(RegressionSlopeValidator);
|
||||
}
|
||||
|
@ -26,8 +26,8 @@ export function main() {
|
||||
|
||||
function createValidator(size) {
|
||||
validator = ReflectiveInjector.resolveAndCreate([
|
||||
SizeValidator.BINDINGS,
|
||||
bind(SizeValidator.SAMPLE_SIZE).toValue(size)
|
||||
SizeValidator.PROVIDERS,
|
||||
provide(SizeValidator.SAMPLE_SIZE).toValue(size)
|
||||
])
|
||||
.get(SizeValidator);
|
||||
}
|
||||
|
@ -59,10 +59,10 @@ export function main() {
|
||||
log = [];
|
||||
extension =
|
||||
ReflectiveInjector.resolveAndCreate([
|
||||
ChromeDriverExtension.BINDINGS,
|
||||
bind(WebDriverAdapter)
|
||||
ChromeDriverExtension.PROVIDERS,
|
||||
provide(WebDriverAdapter)
|
||||
.toValue(new MockDriverAdapter(log, perfRecords, messageMethod)),
|
||||
bind(Options.USER_AGENT).toValue(userAgent)
|
||||
provide(Options.USER_AGENT).toValue(userAgent)
|
||||
])
|
||||
.get(ChromeDriverExtension);
|
||||
return extension;
|
||||
|
@ -38,7 +38,7 @@ export function main() {
|
||||
}
|
||||
log = [];
|
||||
extension = ReflectiveInjector.resolveAndCreate([
|
||||
IOsDriverExtension.BINDINGS,
|
||||
IOsDriverExtension.PROVIDERS,
|
||||
provide(WebDriverAdapter,
|
||||
{useValue: new MockDriverAdapter(log, perfRecords)})
|
||||
])
|
||||
|
Reference in New Issue
Block a user