(slice, inherited, inScript)
| 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 | } |
no test coverage detected