MCPcopy Create free account
hub / github.com/adobe/react-spectrum / visit

Function visit

perf/trace.mjs:99–116  ·  view source on GitHub ↗
(slice, inherited, inScript)

Source from the content-addressed store, hash-verified

97 let totals = {script: 0, style: 0, layout: 0, paint: 0, gc: 0, other: 0, forced: 0};
98 let clipped = (from, to) => Math.max(0, Math.min(to, end.ts) - Math.max(from, begin.ts));
99 let visit = (slice, inherited, inScript) => {
100 let own = classify(slice.name);
101 let bucket = inherited === 'gc' ? 'gc' : (own ?? inherited ?? 'other');
102 let self = 0;
103 let cursor = slice.start;
104 for (let child of slice.children) {
105 self += clipped(cursor, child.start);
106 cursor = Math.max(cursor, child.end);
107 }
108 self += clipped(cursor, slice.end);
109 totals[bucket] += self;
110 if (inScript && (bucket === 'style' || bucket === 'layout')) {
111 totals.forced += self;
112 }
113 for (let child of slice.children) {
114 visit(child, bucket, inScript || bucket === 'script');
115 }
116 };
117 for (let root of roots) {
118 visit(root, null, false);
119 }

Callers 1

summarizeTraceFunction · 0.70

Calls 2

classifyFunction · 0.85
clippedFunction · 0.85

Tested by

no test coverage detected