用途:该技能用于对 React Native(Hermes)应用做性能剖析,测量重渲染与 CPU 表现,配套 argent-react-native-optimization 使用,而非替代它。官方资料未说明其独立安装命令。
主要能力:react-profiler-start 启动 CPU 采样并注入 React commit 捕获钩子;react-profiler-stop 停止录制并在会话中保存 cpuProfile 与 commitTree;react-profiler-status 查询会话状态(active、taken_over、stopped、no_react_runtime),无副作用;react-profiler-analyze 生成按 totalRenderMs 降序的 CPU 增强热点 commit 报告并落盘原始数据;react-profiler-component-source 做 AST 查询(文件、行号、memoization 状态与 50 行源码);react-profiler-renders 与 react-profiler-fiber-tree 无需会话即可实时查看渲染次数、耗时与组件层级。查询工具包括 profiler-cpu-query、profiler-commit-query、profiler-stack-query、profiler-combined-report、profiler-load。
使用方式:先与用户确定成功标准;在同一 device_id 下并行调用 react-profiler-start 与 native-profiler-start,记录 startedAtEpochMs;每次手势后用返回的 timestampMs 计算 offsetMs 并标注;并行停止两个 profiler;调用 react-profiler-analyze(传 port、device_id、project_root、platform、rn_version、annotations);双 profiler 时再调用 profiler-combined-report。之后用查询工具逐层深挖,修复后用 profiler-load 重载旧会话对比,并重新剖析。建议用 flow 固化交互序列以便复现。
限制:不支持物理 iPhone,react-profiler-* 拒绝 kind: "device",需在模拟器上剖析;dev 模式渲染约比生产慢 3 倍,应优先看 normalizedRenderCount;Strict Mode 会双调用渲染;调试器断开会终止剖析;profiler 自身开销会抬高 CPU 读数。少数变化(约 10-15% 以内)可能属噪声。资料未提供收费与价格信息。