Created
March 15, 2022 19:12
-
-
Save jimmyoneill/50ef4864f3515329219830657cafdcbe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calculateOwnTime(rootSpan, fetchSpans): | |
ownTime = 0 | |
maxEndTimeSoFar = rootSpan.startTime | |
sortedFetchSpans = fetchSpans sorted by increasing start-time | |
for fetchSpan in sortedFetchSpans: | |
if (maxEndTimeSoFar < fetchSpan.startTime) | |
ownTime += (fetchSpan.startTime - maxEndTimeSoFar) | |
maxEndTimeSoFar = max(maxEndTimeSoFar, fetchSpan.endTime) | |
ownTime += (rootSpan.endTime - maxEndTimeSoFar) | |
return ownTime |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment