跳到主要内容

Profiler

✅️️ Methods

🔨Profiler.disable


🔨Profiler.enable


🔨Profiler.getBestEffortCoverage

为当前隔离环境收集覆盖率数据。由于垃圾回收,覆盖率数据可能不完整。

EN
Collect coverage data for the current isolate. The coverage data may be incomplete due to garbage collection.
返回对象类型描述原文
resultarray[ScriptCoverage]当前隔离区的覆盖率数据。
ENCoverage data for the current isolate.

🔨Profiler.setSamplingInterval

更改CPU性能分析器的采样间隔。必须在开始记录CPU性能分析之前调用。

EN
Changes CPU profiler sampling interval. Must be called before CPU profiles recording started.
参数必填标记类型描述原文
interval✔️integer新的采样间隔,单位为微秒。
ENNew sampling interval in microseconds.

🔨Profiler.start


🔨Profiler.startPreciseCoverage

启用精确代码覆盖率。启用前执行的JavaScript代码覆盖率数据可能不完整。启用此功能会阻止运行优化代码并重置执行计数器。

EN
Enable precise code coverage. Coverage data for JavaScript executed before enabling precise code coverage may be incomplete. Enabling prevents running optimized code and resets execution counters.
参数必填标记类型描述原文
callCountboolean收集准确的调用次数,而不仅仅是简单的“已覆盖”或“未覆盖”。
ENCollect accurate call counts beyond simple 'covered' or 'not covered'.
detailedboolean收集基于块的覆盖率。
ENCollect block-based coverage.
allowTriggeredUpdatesboolean允许后端主动发送更新
ENAllow the backend to send updates on its own initiative
返回对象类型描述原文
timestampnumber后端获取覆盖率更新时的单调递增时间(以秒为单位)。
ENMonotonically increasing time (in seconds) when the coverage update was taken in the backend.

🔨Profiler.stop

返回对象类型描述原文
profileProfile已录制的配置文件。
ENRecorded profile.

🔨Profiler.stopPreciseCoverage

禁用精确代码覆盖率。禁用会释放不必要的执行计数记录,并允许执行优化后的代码。

EN
Disable precise code coverage. Disabling releases unnecessary execution count records and allows executing optimized code.

🔨Profiler.takePreciseCoverage

收集当前隔离(isolate)的覆盖率数据,并重置执行计数器。需要已启动精确代码覆盖率(Precise code coverage)功能。

EN
Collect coverage data for the current isolate, and resets execution counters. Precise code coverage needs to have started.
返回对象类型描述原文
resultarray[ScriptCoverage]当前隔离的覆盖率数据。
ENCoverage data for the current isolate.
timestampnumber后端获取覆盖率更新时的单调递增时间(以秒为单位)。
ENMonotonically increasing time (in seconds) when the coverage update was taken in the backend.

✅️️ Events

👋Profiler.consoleProfileFinished

参数必填标记类型描述原文
id✔️string
location✔️Debugger.Locationconsole.profileEnd() 的位置。
ENLocation of console.profileEnd().
profile✔️Profile
titlestring作为参数传递给 console.profile() 的配置文件标题。
ENProfile title passed as an argument to console.profile().

👋Profiler.consoleProfileStarted

当使用 console.profile() 调用开始新的性能分析记录时发送。

EN
Sent when new profile recording is started using console.profile() call.
参数必填标记类型描述原文
id✔️string
location✔️Debugger.Locationconsole.profile() 的位置。
ENLocation of console.profile().
titlestring作为参数传递给console.profile()的性能分析标题。
ENProfile title passed as an argument to console.profile().

👋Profiler.preciseCoverageDeltaUpdate🧪

报告自上次轮询以来的覆盖差异(可能来自类似这样的事件,或来自当前隔离的 takePreciseCoverage 方法)。仅在已启动精确代码覆盖时可能发送。此事件可由嵌入程序触发,例如,在特定时间点立即触发覆盖数据的收集。

EN
Reports coverage delta since the last poll (either from an event like this, or from takePreciseCoverage for the current isolate. May only be sent if precise code coverage has been started. This event can be trigged by the embedder to, for example, trigger collection of coverage data immediately at a certain point in time.
参数必填标记类型描述原文
timestamp✔️number后端获取覆盖率更新时的单调递增时间(以秒为单位)。
ENMonotonically increasing time (in seconds) when the coverage update was taken in the backend.
occasion✔️string用于区分覆盖事件的标识符。
ENIdentifier for distinguishing coverage events.
result✔️array[ScriptCoverage]当前隔离环境的覆盖率数据。
ENCoverage data for the current isolate.

✅️️ Types

📌Profiler.CoverageRange

源范围的覆盖数据。

EN
Coverage data for a source range.

返回类型:object

属性必填标记类型描述原文
startOffset✔️integerJavaScript脚本源偏移量,用于范围起始。
ENJavaScript script source offset for the range start.
endOffset✔️integerJavaScript脚本源偏移量,用于范围结束。
ENJavaScript script source offset for the range end.
count✔️integer收集了源代码范围的执行次数。
ENCollected execution count of the source range.

📌Profiler.FunctionCoverage

JavaScript函数的覆盖率数据。

EN
Coverage data for a JavaScript function.

返回类型:object

属性必填标记类型描述原文
functionName✔️stringJavaScript函数名称。
ENJavaScript function name.
ranges✔️array[CoverageRange]函数内部包含覆盖率数据的源代码范围。
ENSource ranges inside the function with coverage data.
isBlockCoverage✔️boolean此函数的覆盖率数据是否具有块粒度。
ENWhether coverage data for this function has block granularity.

📌Profiler.PositionTickInfo

指定归属于特定源代码位置的样本数量。

EN
Specifies a number of samples attributed to a certain source position.

返回类型:object

属性必填标记类型描述原文
line✔️integer源文件行号(从1开始计数)。
ENSource line number (1-based).
ticks✔️integer归属于源行的样本数量。
ENNumber of samples attributed to the source line.

📌Profiler.Profile

Profile。

EN
Profile.

返回类型:object

属性必填标记类型描述原文
nodes✔️array[ProfileNode]配置文件节点列表。第一个项目是根节点。
ENThe list of profile nodes. First item is the root node.
startTime✔️number性能分析开始时间戳,以微秒为单位。
ENProfiling start timestamp in microseconds.
endTime✔️number性能分析结束时间戳,单位为微秒。
ENProfiling end timestamp in microseconds.
samplesarray[integer]样本顶层节点的标识符。
ENIds of samples top nodes.
timeDeltasarray[integer]相邻样本之间的时间间隔,以微秒为单位。第一个时间差是相对于配置文件开始时间(startTime)的。
ENTime intervals between adjacent samples in microseconds. The first delta is relative to the profile startTime.

📌Profiler.ProfileNode

Profile节点。包含调用站点信息、执行统计数据和子节点信息。

EN
Profile node. Holds callsite information, execution statistics and child nodes.

返回类型:object

属性必填标记类型描述原文
id✔️integer节点的唯一标识符。
ENUnique id of the node.
callFrame✔️Runtime.CallFrame函数位置。
ENFunction location.
hitCountinteger此节点位于调用堆栈顶部的样本数量。
ENNumber of samples where this node was on top of the call stack.
childrenarray[integer]子节点ID。
ENChild node ids.
deoptReasonstring未优化的原因。该函数可能被''deoptimized''或标记为don't optimize
ENThe reason of being not optimized. The function may be deoptimized or marked as don't optimize.
positionTicksarray[PositionTickInfo]一个源位置刻度的数组。
ENAn array of source position ticks.

📌Profiler.ScriptCoverage

JavaScript脚本的覆盖率数据。

EN
Coverage data for a JavaScript script.

返回类型:object

属性必填标记类型描述原文
scriptId✔️Runtime.ScriptIdJavaScript 脚本 ID。
ENJavaScript script id.
url✔️stringJavaScript 脚本名称或 URL。
ENJavaScript script name or url.
functions✔️array[FunctionCoverage]包含覆盖率数据的脚本中的函数。
ENFunctions contained in the script that has coverage data.