Skip to content

Commit

Permalink
Refactor the changes
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Gaponov <[email protected]>
  • Loading branch information
maxgaponov committed Nov 29, 2023
1 parent 8d3593d commit ba8fde9
Showing 1 changed file with 2 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,6 @@ function getChildOfSpans(parentID: string, allSpans: Span[]): Span[] {
return memoizedParentChildOfMap(allSpans)[parentID] || [];
}

function getChildOfDrange(parentID: string, allSpans: Span[]) {
const childrenDrange = new DRange();
getChildOfSpans(parentID, allSpans).forEach(s => {
// -1 otherwise it will take for each child a micro (incluse,exclusive)
childrenDrange.add(10 * s.startTime, 10 * (s.startTime + Math.max(s.duration, 0)) - 1);
});
return childrenDrange;
}

function computeSelfTime(span: Span, allSpans: Span[]): number {
// We want to represent spans as half-open intervals like [startTime, startTime + duration).
// This way the subtraction preserves the right boundaries. However, DRange treats all
Expand All @@ -65,8 +56,8 @@ function computeSelfTime(span: Span, allSpans: Span[]): number {
if (!span.hasChildren) return span.duration;
const spanRange = new DRange(10 * span.startTime, 10 * (span.startTime + span.duration) - 1);
const children = getChildOfSpans(span.spanID, allSpans);
children.forEach(child => {
spanRange.subtract(10 * child.startTime, 10 * (child.startTime + child.duration) - 1);
children.forEach(child =>
spanRange.subtract(10 * child.startTime, 10 * (child.startTime + child.duration) - 1)
);
return Math.round(spanRange.length / 10);
}
Expand Down

0 comments on commit ba8fde9

Please sign in to comment.