MCPcopy
hub / github.com/angular/angular / runBenchmark

Function runBenchmark

modules/utilities/perf_util.ts:30–69  ·  view source on GitHub ↗
({
  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) | (() => Promise<unknown>);
  prepare?: (() => void) | (() => Promise<unknown>);
  setup?: (() => void) | (() => Promise<unknown>);
})

Source from the content-addressed store, hash-verified

28let _cachedBenchpressSetup: Promise<BenchpressSetup> | null = null;
29
30export async function runBenchmark({
31 id,
32 url = '',
33 params = [],
34 ignoreBrowserSynchronization = true,
35 microMetrics,
36 work,
37 prepare,
38 setup,
39}: {
40 id: string;
41 url?: string;
42 params?: {name: string; value: any}[];
43 ignoreBrowserSynchronization?: boolean;
44 microMetrics?: {[key: string]: string};
45 work?: (() => void) | (() => Promise<unknown>);
46 prepare?: (() => void) | (() => Promise<unknown>);
47 setup?: (() => void) | (() => Promise<unknown>);
48}): Promise<any> {
49 if (_cachedBenchpressSetup === null) {
50 _cachedBenchpressSetup = _prepareBenchpressSetup();
51 }
52
53 // Wait for the benchpress setup to complete initialization.
54 // The benchpress setup is loaded asynchronously due to it relying on ESM.
55 // TODO: This can be removed when benchmark tests/e2e tests can run with ESM.
56 const {module, runner} = await _cachedBenchpressSetup;
57
58 openBrowser({url, params, ignoreBrowserSynchronization});
59 if (setup) {
60 await setup();
61 }
62 return runner.sample({
63 id,
64 execute: work,
65 prepare,
66 microMetrics,
67 providers: [{provide: module.Options.SAMPLE_DESCRIPTION, useValue: {}}],
68 });
69}
70
71async function _prepareBenchpressSetup(): Promise<BenchpressSetup> {
72 const module = await loadBenchpressModule();

Callers 11

runTableBenchmarkFunction · 0.85
runBenchmarkScenarioFunction · 0.85
runLargeFormBenchmarkFunction · 0.85
runTableBenchmarkFunction · 0.85
runStylingBenchmarkFunction · 0.85
runTableBenchmarkFunction · 0.85
runTreeBenchmarkFunction · 0.85
runTableBenchmarkFunction · 0.85

Calls 4

openBrowserFunction · 0.90
_prepareBenchpressSetupFunction · 0.85
setupFunction · 0.50
sampleMethod · 0.45

Tested by 1

runStylingBenchmarkFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…