JS Self-Profiling API
The samplebufferfull event of the Profiler interface is fired when the number of samples the profiler has recorded matches the maxBufferSize value passed to the profiler's constructor.
After this event fires, the profiler will not record any more samples.
This event is not cancelable and does not bubble.
Syntax
Use the event name in EventTarget/addEventListener:
addEventListener("samplebufferfull", (event) => { })
Alternatively, assign to the event handler property of the interface:
onsamplebufferfull = (event) => { }
Event type
An Event.
Examples
const profiler = new Profiler({ sampleInterval: 10, maxBufferSize: 100 });
profiler.addEventListener("samplebufferfull", async () => {
console.log("Sample buffer full!");
const trace = await profiler.stop();
console.log(JSON.stringify(trace));
});
Specifications
Browser compatibility
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
