Last active
November 25, 2024 10:40
-
-
Save noamr/f8b1b3fe042f7359b1146318cd19786c 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
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