Last active
November 12, 2018 20:37
-
-
Save gregtatum/da11b610c2d76c6e70c2897a21d9282e to your computer and use it in GitHub Desktop.
This file contains 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
// Use this on profiles to extract screenshot and arbitrary marker information. | |
// Example profile: https://perfht.ml/2T7kA2i | |
function getMarkersByName(thread, name) { | |
const { markers, stringTable } = thread; | |
const stringIndex = stringTable.indexForString(name); | |
const results = []; | |
for (let markerIndex = 0; markerIndex < markers.length; markerIndex++) { | |
if (markers.name[markerIndex] === stringIndex) { | |
results.push({ | |
data: markers.data[markerIndex], | |
time: markers.time[markerIndex] | |
}); | |
} | |
} | |
return results; | |
} | |
{ | |
var compositorThread = profile.threads.find(thread => thread.name === 'Compositor') | |
var contentThreads = profile.threads.filter( | |
thread => thread.name === 'GeckoMain' && thread.processType === 'tab' | |
); | |
// Select whatever events you are interested in, here it's grabbing markers by name. | |
var domEvents = contentThreads.map(thread => getMarkersByName(thread, "DOMEvent")) | |
// The screenshots contain the "data" payload, which includes the base64 encoded screenshot. | |
var screenshots = getMarkersByName(compositorThread, 'CompositorScreenshot') | |
console.log({ domEvents, screenshots }) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment