weightedNode.tsx 602 B

12345678910111213141516171819
  1. /**
  2. * This is a utility class for profiling (inspired from Speedscope) - we extend it in order to be able to construct
  3. * a stack of nodes (or call trees) and append weights to them.
  4. */
  5. export class WeightedNode {
  6. // Total weight is the weight of the node and all its children.
  7. totalWeight: number = 0;
  8. // Self weight is the weight of the node itself.
  9. selfWeight: number = 0;
  10. addToTotalWeight(delta: number): number {
  11. this.totalWeight += delta;
  12. return this.totalWeight;
  13. }
  14. addToSelfWeight(delta: number): number {
  15. this.selfWeight += delta;
  16. return this.selfWeight;
  17. }
  18. }