native-app-performance
它能做什么
这个技能使用 Apple 的命令行工具录制 Time Profiler 跟踪,然后在不打开 Instruments 的情况下对热点进行排名。适合排查原生应用运行缓慢问题的开发者。
适用场景
- ✓原生 Mac 或 iOS 应用运行缓慢,你想找出耗时的代码的时候。
- ✓你希望从命令行录制应用的性能数据,而不是在应用内录制的时候。
- ✓跟踪结果的调用栈为空,需要重新捕获缓慢操作的时候。
技能链接
https://github.com/steipete/agent-scripts/blob/main/skills/native-app-performance/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请在我执行缓慢操作时,为我的应用录制 90 秒的性能跟踪,并列出最主要的热点。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体使用 xctrace 工具录制跟踪,提取时间采样数据,找到加载地址,并用随附的脚本对最耗时的函数进行排名。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Native App Performance (CLI-only)
Goal: record Time Profiler via xctrace, extract samples, symbolicate, and propose hotspots without opening Instruments.
Quick start (CLI)
- Record Time Profiler (attach):
# Start app yourself, then attach
xcrun xctrace record --template 'Time Profiler' --time-limit 90s --output /tmp/App.trace --attach <pid>
- Record Time Profiler (launch):
xcrun xctrace record --template 'Time Profiler' --time-limit 90s --output /tmp/App.trace --launch -- /path/App.app/Contents/MacOS/App
- Extract time samples:
scripts/extract_time_samples.py --trace /tmp/App.trace --output /tmp/time-sample.xml
- Get load address for symbolication:
# While app is running
vmmap <pid> | rg -m1 "__TEXT" -n
- Symbolicate + rank hotspots:
scripts/top_hotspots.py --samples /tmp/time-sample.xml \
--binary /path/App.app/Contents/MacOS/App \
--load-address 0x100000000 --top 30
Workflow notes
- Always confirm you’re profiling the correct binary (local build vs /Applications). Prefer direct binary path for
--launch. - Ensure you trigger the slow path during capture (menu open/close, refresh, etc.).
- If stacks are empty, capture longer or avoid idle sections.
xcrun xctrace help recordandxcrun xctrace help exportshow correct flags.
Included scripts
scripts/record_time_profiler.sh: record via attach or launch.scripts/extract_time_samples.py: export time-sample XML from a trace.scripts/top_hotspots.py: symbolicate and rank top app frames.
Gotchas
- ASLR means you must use the runtime
__TEXTload address fromvmmap. - If using a new build, update the
--binarypath; symbols must match the trace. - CLI-only flow: no need to open Instruments if stacks are symbolicated via
atos.
常见问题
我需要打开 Instruments 吗?
不需要。技能在命令行中完成性能分析,无需打开 Instruments。
为什么跟踪结果可能不准确?
技能警告,可能分析到了错误的应用副本,因此应指定确切的二进制路径。
如果调用栈为空怎么办?
技能建议延长录制时间,或避开空闲的部分。
详情
作者的原始描述
Native app performance: xctrace, Time Profiler, traces, hotspots.
repo: steipete/agent-scripts
热度
- GitHub 星标
- 7.4k
- 排名
- #13237
- 许可证
- MIT
- 更新时间
- 2026/10/30
评论
- …
同一仓库的更多技能
beeper
7.4k帮你的智能体搜索本地 Beeper 聊天记录,找到消息,并判断模糊线索指的是哪个聊天或联系人。
cloudflare-registrar
7.4k帮你的智能体查询 Cloudflare Registrar 的域名价格和可用性,并在确认后注册或列出域名。
codexbar
7.4k帮你的智能体查看你在 Codex、Claude、Kimi 等 AI 服务中还剩多少用量,包括限额、额度和重置时间。
create-cli
7.4k帮你的智能体设计命令行工具的命令、参数、帮助文本、输出和错误提示,让人和脚本都能顺利使用。