Skip to content

Instantly share code, notes, and snippets.

@gregtatum
Last active November 12, 2018 20:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gregtatum/da11b610c2d76c6e70c2897a21d9282e to your computer and use it in GitHub Desktop.
Save gregtatum/da11b610c2d76c6e70c2897a21d9282e to your computer and use it in GitHub Desktop.
// 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