跳至主内容
版本:0.80

Systrace

非官方测试版翻译

本页面由 PageTurner AI 翻译(测试版)。未经项目官方认可。 发现错误? 报告问题 →

Systrace 是标准的 Android 基于标记的性能分析工具(安装 Android 平台工具包时会自动安装)。被分析的代码块由开始/结束标记包围,并以彩色图表形式可视化呈现。Android SDK 和 React Native 框架都提供了可供可视化的标准标记。

示例

Systrace 允许您用标签和整数值标记 JavaScript (JS) 事件。非计时类 JS 事件可在 EasyProfiler 中捕获。


参考

方法

isEnabled()

tsx
static isEnabled(): boolean;

beginEvent()

tsx
static beginEvent(eventName: string | (() => string), args?: EventArgs);

beginEvent/endEvent 用于在同一调用栈帧内启动和结束性能分析。


endEvent()

tsx
static endEvent(args?: EventArgs);

beginAsyncEvent()

tsx
static beginAsyncEvent(
eventName: string | (() => string),
args?: EventArgs,
): number;

beginAsyncEvent/endAsyncEvent 用于启动和结束跨线程或当前栈帧外的性能分析,例如:应使用返回的 cookie 变量作为 endAsyncEvent 调用的输入参数来结束分析。


endAsyncEvent()

tsx
static endAsyncEvent(
eventName: EventName,
cookie: number,
args?: EventArgs,
);

counterEvent()

tsx
static counterEvent(eventName: string | (() => string), value: number);

在 systrace 时间线上将数值注册到 profileName。