Skip to main content

Systrace

Systrace 是一个标准的 Android 基于标记的分析工具(在安装 Android 平台工具包时安装)。分析的代码块被开始/结束标记包围,然后以彩色图表格式可视化。Android SDK 和 React Native 框架都提供了可可视化的标准标记。

¥Systrace is a standard Android marker-based profiling tool (and is installed when you install the Android platform-tools package). Profiled code blocks are surrounded by start/end markers which are then visualized in a colorful chart format. Both the Android SDK and React Native framework provide standard markers that you can visualize.

示例

¥Example

Systrace 允许你使用标签和整数值来标记 JavaScript (JS) 事件。在 EasyProfiler 中捕获非定时 JS 事件。

¥Systrace allows you to mark JavaScript (JS) events with a tag and an integer value. Capture the non-Timed JS events in EasyProfiler.


参考

¥Reference

方法

¥Methods

isEnabled()

static isEnabled(): boolean;

beginEvent()

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

beginEvent/endEvent 用于在同一调用堆栈帧内启动和结束配置文件。

¥beginEvent/endEvent for starting and then ending a profile within the same call stack frame.


endEvent()

static endEvent(args?: EventArgs);

beginAsyncEvent()

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

beginAsyncEvent/endAsyncEvent 用于启动和结束配置文件,其中结束可以发生在另一个线程上或在当前堆栈帧之外,例如,await 返回的 cookie 变量应用作 endAsyncEvent 调用的输入以结束配置文件。

¥beginAsyncEvent/endAsyncEvent for starting and then ending a profile where the end can either occur on another thread or out of the current stack frame, eg await the returned cookie variable should be used as input into the endAsyncEvent call to end the profile.


endAsyncEvent()

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

counterEvent()

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

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

¥Register the value to the profileName on the systrace timeline.