Skip to content

Commit

Permalink
refactor(dev-infra): add default params to runBenchmark (#38748)
Browse files Browse the repository at this point in the history
* Use '' as the default for 'url'
* Use [] as the default for 'params'
* Use true as the default for 'ignoreBrowserSynchronization'

PR Close #38748
  • Loading branch information
wagnermaciel authored and AndrewKushnir committed Sep 11, 2020
1 parent 31d0ee4 commit 6ff9e6e
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions dev-infra/benchmark/driver-utilities/perf_util.ts
Expand Up @@ -23,27 +23,36 @@ const globalOptions = {

const runner = createBenchpressRunner();

export async function runBenchmark(config: {
export async function runBenchmark({
id,
url = '',
params = [],
ignoreBrowserSynchronization = true,
microMetrics,
work,
prepare,
setup,
}: {
id: string,
url: string,
params: {name: string, value: any}[],
ignoreBrowserSynchronization?: boolean,
microMetrics?: {[key: string]: string},
work?: () => void,
prepare?: () => void,
setup?: () => void
work?: (() => void)|(() => Promise<unknown>),
prepare?: (() => void)|(() => Promise<unknown>),
setup?: (() => void)|(() => Promise<unknown>),
}): Promise<any> {
openBrowser(config);
if (config.setup) {
await config.setup();
openBrowser({url, params, ignoreBrowserSynchronization});
if (setup) {
await setup();
}
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({
id: config.id,
execute: config.work,
prepare: config.prepare,
microMetrics: config.microMetrics,
id,
execute: work,
prepare,
microMetrics,
providers: [{provide: Options.SAMPLE_DESCRIPTION, useValue: {}}]
});
}
Expand Down

0 comments on commit 6ff9e6e

Please sign in to comment.