refactor(dev-infra): add default params to runBenchmark (#38748)
* Use '' as the default for 'url' * Use [] as the default for 'params' * Use true as the default for 'ignoreBrowserSynchronization' PR Close #38748
This commit is contained in:
parent
27cc56b359
commit
da14b72550
|
@ -23,27 +23,36 @@ const globalOptions = {
|
||||||
|
|
||||||
const runner = createBenchpressRunner();
|
const runner = createBenchpressRunner();
|
||||||
|
|
||||||
export async function runBenchmark(config: {
|
export async function runBenchmark({
|
||||||
|
id,
|
||||||
|
url = '',
|
||||||
|
params = [],
|
||||||
|
ignoreBrowserSynchronization = true,
|
||||||
|
microMetrics,
|
||||||
|
work,
|
||||||
|
prepare,
|
||||||
|
setup,
|
||||||
|
}: {
|
||||||
id: string,
|
id: string,
|
||||||
url: string,
|
url: string,
|
||||||
params: {name: string, value: any}[],
|
params: {name: string, value: any}[],
|
||||||
ignoreBrowserSynchronization?: boolean,
|
ignoreBrowserSynchronization?: boolean,
|
||||||
microMetrics?: {[key: string]: string},
|
microMetrics?: {[key: string]: string},
|
||||||
work?: () => void,
|
work?: (() => void)|(() => Promise<unknown>),
|
||||||
prepare?: () => void,
|
prepare?: (() => void)|(() => Promise<unknown>),
|
||||||
setup?: () => void
|
setup?: (() => void)|(() => Promise<unknown>),
|
||||||
}): Promise<any> {
|
}): Promise<any> {
|
||||||
openBrowser(config);
|
openBrowser({url, params, ignoreBrowserSynchronization});
|
||||||
if (config.setup) {
|
if (setup) {
|
||||||
await config.setup();
|
await setup();
|
||||||
}
|
}
|
||||||
const description: {[key: string]: any} = {};
|
const description: {[key: string]: any} = {};
|
||||||
config.params.forEach((param) => description[param.name] = param.value);
|
params.forEach((param) => description[param.name] = param.value);
|
||||||
return runner.sample({
|
return runner.sample({
|
||||||
id: config.id,
|
id,
|
||||||
execute: config.work,
|
execute: work,
|
||||||
prepare: config.prepare,
|
prepare,
|
||||||
microMetrics: config.microMetrics,
|
microMetrics,
|
||||||
providers: [{provide: Options.SAMPLE_DESCRIPTION, useValue: {}}]
|
providers: [{provide: Options.SAMPLE_DESCRIPTION, useValue: {}}]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue