Stackprof: stack garbage collection frames on top of previous stack (#85)

We do a similar thing for Chrome to make the flamegraphs more readable
This commit is contained in:
Jamie Wong
2018-07-03 00:23:40 -07:00
committed by GitHub
parent 4b7c255a24
commit 177fb0eb1d
2 changed files with 348 additions and 341 deletions
File diff suppressed because it is too large Load Diff
+8 -1
View File
@@ -21,10 +21,13 @@ export function importFromStackprof(stackprofProfile: StackprofProfile): Profile
const {frames, raw, raw_timestamp_deltas} = stackprofProfile
let sampleIndex = 0
let prevStack: FrameInfo[] = []
for (let i = 0; i < raw.length; ) {
const stackHeight = raw[i++]
const stack: FrameInfo[] = []
let stack: FrameInfo[] = []
for (let j = 0; j < stackHeight; j++) {
const id = raw[i++]
stack.push({
@@ -32,6 +35,9 @@ export function importFromStackprof(stackprofProfile: StackprofProfile): Profile
...frames[id],
})
}
if (stack.length === 1 && stack[0].name === '(garbage collection)') {
stack = prevStack.concat(stack)
}
const nSamples = raw[i++]
let sampleDuration = 0
@@ -40,6 +46,7 @@ export function importFromStackprof(stackprofProfile: StackprofProfile): Profile
}
profile.appendSample(stack, sampleDuration)
prevStack = stack
}
profile.setValueFormatter(new TimeFormatter('microseconds'))