MCPcopy
hub / github.com/Zizzamia/perfume.js / measureSteps

Function measureSteps

src/steps/measureSteps.ts:11–38  ·  view source on GitHub ↗
(mark: string)

Source from the content-addressed store, hash-verified

9} from './navigationSteps';
10
11export const measureSteps = (mark: string) => {
12 if (steps.finalMarkToStepsMap[mark]) {
13 recordEndMark(mark);
14 // this is an end mark so we delete the entry
15 const finalSteps = steps.finalMarkToStepsMap[mark];
16 Object.keys(finalSteps).forEach(startMark => {
17 const possibleSteps = finalSteps[startMark];
18 possibleSteps.forEach(removeActiveStep);
19 // Async processing all possible steps
20 // needs to be async due to clearing previously measured steps and marks.
21 // If we run all concurrently, there is a chance for a race condition
22 // where we are adding and deleteing the entries in WP.Performance which caused the measure to fail.
23 Promise.all(
24 possibleSteps.map(async step => {
25 // measure
26 await measureStep(step, startMark, mark);
27 }),
28 ).catch(() => {
29 // TODO @zizzamia log error
30 });
31 });
32 } else {
33 recordStartMark(mark);
34 addActiveSteps(mark);
35 }
36 const navigationBasedActiveSteps = getActiveStepsFromNavigationSteps();
37 config.onMarkStep?.(mark, Object.keys(navigationBasedActiveSteps));
38};

Callers 2

markStepOnceFunction · 0.90
markStepFunction · 0.90

Calls 5

recordEndMarkFunction · 0.90
measureStepFunction · 0.90
recordStartMarkFunction · 0.90
addActiveStepsFunction · 0.90

Tested by

no test coverage detected