contentTracing¶
从 Chromium 收集跟踪数据,以查找性能瓶颈和缓慢操作。
进程:主进程
此模块不包含 Web 界面。要查看已记录的跟踪,请使用
trace viewer,可在 Chrome 中的 chrome://tracing 访问。
[!NOTE] 在 app 模块的
ready事件发出之前,不应使用此模块。
const { app, contentTracing } = require('electron')
app.whenReady().then(() => {
(async () => {
await contentTracing.startRecording({
included_categories: ['*']
})
console.log('Tracing started')
await new Promise(resolve => setTimeout(resolve, 5000))
const path = await contentTracing.stopRecording()
console.log('Tracing data recorded to ' + path)
})()
})
方法¶
contentTracing 模块具有以下方法:
contentTracing.getCategories()¶
options(TraceConfig | TraceCategoriesAndOptions)
返回 Promise<void> - 当所有子进程确认 startRecording 请求后解析。
在所有进程上开始记录。
记录会在本地立即开始,并在子进程收到 EnableRecording 请求后异步开始。
如果已有记录正在运行,Promise 将立即解析,因为同一时间只能有一个跟踪操作正在进行。
contentTracing.stopRecording([resultFilePath])¶
返回 Promise<Object> - 解析为包含跟踪缓冲区最大使用量的 value 和 percentage 的对象
valuenumberpercentagenumber
获取跨进程跟踪缓冲区的最大使用量,作为完整状态的百分比。
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 el/electron