Profiler
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimentell: Dies ist eine experimentelle Technologie
Überprüfen Sie die Browser-Kompatibilitätstabelle sorgfältig vor der Verwendung auf produktiven Webseiten.
Das Profiler
-Interface der JS Self-Profiling API ermöglicht es Ihnen, ein Profil eines Teils der Ausführung Ihrer Webanwendung zu erstellen.
Konstruktor
Profiler()
Experimentell-
Erstellt ein neues
Profiler
-Objekt und beginnt mit der Sammlung von Proben.
Instanzmethoden
Profiler.stop()
Experimentell-
Stoppt den Profiler und gibt ein
Promise
zurück, das sich in das Profil auflöst.
Ereignisse
samplebufferfull
-
Wird ausgelöst, wenn das Profil genügend Proben aufgenommen hat, um seinen internen Puffer zu füllen.
Beispiele
Aufnahme eines Profils
Der folgende Code profiliert die doWork()
-Operation und protokolliert das Ergebnis.
const profiler = new Profiler({ sampleInterval: 10, maxBufferSize: 10000 });
doWork();
const profile = await profiler.stop();
console.log(JSON.stringify(profile));
Profilieren des Seitenladevorgangs
Der folgende Code profiliert die Zeit zwischen dem ersten Ausführen des Skripts und dem Auslösen des load
-Ereignisses des Fensters.
const profiler = new Profiler({ sampleInterval: 10, maxBufferSize: 10000 });
window.addEventListener("load", async () => {
const profile = await profiler.stop();
console.log(JSON.stringify(profile));
});
Spezifikationen
Specification |
---|
JS Self-Profiling API # the-profiler-interface |