(ctx: AnalysisContext)
| 499 | } |
| 500 | |
| 501 | const buildCallTree = (ctx: AnalysisContext): void => { |
| 502 | // This message goes to outputCapture for the summary file |
| 503 | outputCapture.write( |
| 504 | `Building call tree from ${ctx.callRanges.length} ranges...` |
| 505 | ) |
| 506 | ctx.callRanges.sort((a, b) => a.startTime - b.startTime) |
| 507 | const activeCallStack: CallRange[] = [] |
| 508 | |
| 509 | for (const call of ctx.callRanges) { |
| 510 | while ( |
| 511 | activeCallStack.length > 0 && |
| 512 | activeCallStack[activeCallStack.length - 1].endTime < call.startTime |
| 513 | ) |
| 514 | activeCallStack.pop() |
| 515 | |
| 516 | if (activeCallStack.length === 0) ctx.rootCalls.push(call) |
| 517 | else { |
| 518 | const parent = activeCallStack[activeCallStack.length - 1] |
| 519 | parent.children.push(call) |
| 520 | } |
| 521 | activeCallStack.push(call) |
| 522 | } |
| 523 | outputCapture.write( |
| 524 | `Call tree built with ${ctx.rootCalls.length} root calls.` |
| 525 | ) |
| 526 | } |
| 527 | |
| 528 | const calculateSelfTimes = (call: CallRange): number => { |
| 529 | let childrenTime = 0 |
no test coverage detected