Skip to content

Instantly share code, notes, and snippets.

@noamr
Last active November 25, 2024 10:40
Show Gist options
  • Save noamr/f8b1b3fe042f7359b1146318cd19786c to your computer and use it in GitHub Desktop.
Save noamr/f8b1b3fe042f7359b1146318cd19786c to your computer and use it in GitHub Desktop.
const track = new PerformanceTrack();
// At some point
track.mark(name);
// At some other point
track.mark(name);
// Combines mark->mark as a single entry with duration
track.measure(name);
// Gives devtools additional information about this track
console.describeTrack(track, { color: "blue", track: "framework" });
const observer = new PerformanceObserver(entries => {
for (const loaf : entries.getEntriesByType("long-animation-frame") {
// This will have all the marks&measures from the attached tracks
loaf.tracks
// This will have now also include functions captured with track.bind
loaf.scripts
}
});
observer.observe({entryType: "long-animation-frame"});
observer.attachTrack(track);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment