MCPcopy Create free account
hub / github.com/angular/dev-infra / measureWorkflow

Function measureWorkflow

ng-dev/perf/workflow/workflow.ts:5–43  ·  view source on GitHub ↗
({name, workflow, prepare, cleanup}: Workflow)

Source from the content-addressed store, hash-verified

3import {Workflow} from './loader.js';
4
5export async function measureWorkflow({name, workflow, prepare, cleanup}: Workflow) {
6 const spinner = new Spinner();
7 try {
8 if (prepare) {
9 spinner.update('Preparing environment for workflow execution');
10 // Run the `prepare` commands to establish the environment, caching, etc prior to running the
11 // workflow.
12 await runCommands(prepare);
13 spinner.update('Environment preperation completed');
14 }
15
16 spinner.update(`Executing workflow (${name})`);
17 // Mark the start time of the workflow, execute all of the commands provided in the workflow and
18 // then mark the ending time.
19 performance.mark('start');
20 await runCommands(workflow);
21 performance.mark('end');
22
23 spinner.update('Workflow completed');
24
25 if (cleanup) {
26 spinner.update('Cleaning up environment after workflow');
27 // Run the clean up commands to reset the environment and undo changes made during the workflow.
28 await runCommands(cleanup);
29 spinner.update('Environment cleanup complete');
30 }
31
32 const results = performance.measure(name, 'start', 'end');
33
34 spinner.success(`${name}: ${results.duration.toFixed(2)}ms`);
35
36 return {
37 name,
38 value: results.duration,
39 };
40 } finally {
41 spinner.complete();
42 }
43}
44
45/**
46 * Run a set of commands provided as a multiline text block. Commands are assumed to always be

Callers 1

handlerFunction · 0.85

Calls 4

updateMethod · 0.95
successMethod · 0.95
completeMethod · 0.95
runCommandsFunction · 0.85

Tested by

no test coverage detected