返回顶部
i

instruments-profilingInstruments分析

Use when profiling native macOS or iOS apps with Instruments/xctrace. Covers correct binary selection, CLI arguments, exports, and common gotchas.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
2,261
下载量
免费
免费
3
收藏
概述
安装方式
版本历史

instruments-profiling

性能分析工具 (macOS/iOS)

当用户需要对原生应用进行性能分析或堆栈分析时使用此技能。
重点:时间分析器、xctrace 命令行工具,以及选择正确的二进制/应用实例。

快速入门 (命令行)

  • - 列出模板:xcrun xctrace list templates
  • 录制时间分析器(启动):
- xcrun xctrace record --template Time Profiler --time-limit 60s --output /tmp/App.trace --launch -- /path/To/App.app
  • - 录制时间分析器(附加):
- 自行启动应用,获取PID,然后: - xcrun xctrace record --template Time Profiler --time-limit 60s --output /tmp/App.trace --attach
  • - 在Instruments中打开跟踪:
- open -a Instruments /tmp/App.trace

注意:xcrun xctrace --help 不是有效的子命令。请使用 xcrun xctrace help record。

选择正确的二进制文件(关键)

陷阱:如果LaunchServices解析了不同的bundle,Instruments可能会分析错误的应用程序(例如,/Applications中的那个)。
请遵循以下规则:

  • - 优先使用直接二进制路径进行确定性启动:
- xcrun xctrace record ... --launch -- /path/App.app/Contents/MacOS/App
  • - 如果启动.app,确保是预期的bundle:
- open -n /path/App.app - 使用 ps -p -o comm= -o command= 验证
  • - 如果同时存在 /Applications/App.app 和本地构建版本,明确指定本地构建路径。
  • 启动后,在信任跟踪结果前确认进程路径。

命令参数 (xctrace)

  • - --template Time Profiler:来自 xctrace list templates 的模板名称。
  • --launch -- :-- 之后的所有内容都是目标命令(二进制文件或应用bundle)。
  • --attach :附加到正在运行的进程。
  • --output :.trace 输出文件。如果省略,文件保存在当前工作目录。
  • --time-limit 60s|5m:设置捕获持续时间。
  • --device :iOS设备运行必需。
  • --target-stdout -:将启动进程的标准输出流式传输到终端(对命令行工具很有用)。

导出堆栈 (命令行)

  • - 检查跟踪表:
- xcrun xctrace export --input /tmp/App.trace --toc
  • - 导出原始时间分析样本:
- xcrun xctrace export --input /tmp/App.trace --xpath /trace-toc/run[@number=1]/data/table[@schema=time-profile] --output /tmp/time-profile.xml
  • - 在脚本(Python/Rust)中进行后处理以聚合堆栈。

Instruments UI 工作流程

  • - 模板:时间分析器
  • 使用录制并捕获慢路径(启动 vs 稳态)
  • 调用树提示:
- 隐藏系统库 - 反转调用树 - 按线程分离 - 关注热点帧和调用次数

陷阱与修复

  • - 分析了错误的应用程序:LaunchServices解析已安装的应用而不是本地构建版本。
- 修复:使用直接二进制路径或使用已知PID的 --attach。
  • - 没有样本/空跟踪:应用快速退出或从未执行工作负载。
- 修复:更长的捕获时间,在录制期间触发工作负载。
  • - 隐私提示:xctrace 可能需要开发者工具权限。
- 修复:系统设置 → 隐私与安全性 → 开发者工具 → 允许终端/Xcode。
  • - 大型XML导出:time-profile 导出文件很大。
- 修复:使用XPath过滤并离线聚合;不要打印到终端。

iOS 特定说明

  • - 设备:使用 xcrun xctrace list devices 和 --device
  • 如果需要,通过Xcode启动;使用 xctrace --attach 附加。
  • 确保调试符号以获得有意义的堆栈。

验证检查清单

  • - 确认跟踪进程路径与目标构建版本匹配。
  • 确认堆栈显示预期的应用帧。
  • 捕获覆盖慢操作(启动/刷新)。
  • 导出堆栈以进行自动化差异比较(如果正在优化)。

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 instruments-profiling-1776396542 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 instruments-profiling-1776396542 技能

通过命令行安装

skillhub install instruments-profiling-1776396542

下载

⬇ 下载 instruments-profiling v1.0.0(免费)

文件大小: 2.35 KB | 发布时间: 2026-4-17 15:19

v1.0.0 最新 2026-4-17 15:19

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部