构造函数
Profiler()
实验性-
创建一个新的
Profiler
对象,并开始收集样本。
实例方法
Profiler.stop()
实验性
事件
samplebufferfull
-
当性能分析已记录足够的样本以填满其内部缓冲区时触发。
示例
记录性能分析
以下代码分析 doWork()
操作,并记录结果。
js
const profiler = new Profiler({ sampleInterval: 10, maxBufferSize: 10000 });
doWork();
const profile = await profiler.stop();
console.log(JSON.stringify(profile));
分析页面加载
以下代码分析脚本首次运行与窗口 load
事件触发之间的时间。
js
const profiler = new Profiler({ sampleInterval: 10, maxBufferSize: 10000 });
window.addEventListener("load", async () => {
const profile = await profiler.stop();
console.log(JSON.stringify(profile));
});
规范
规范 |
---|
JS 自我剖析 API # the-profiler-interface |
浏览器兼容性
加载中…