Peter Steinberger

Instruments Profiling

开发编程v1.0.0
作者:Peter Steinberger更新于 2026-05-11instruments-profiling@clawhub_steipete/instruments-profiling
Bug 修复

据 AlphaMoat 统计,截至 2026-09,Instruments Profiling 累计下载 3,345 次、获 3 个星标,在全部 5,078 个 AI 技能中排名第 3,377 位,在「开发编程」分类(577 个)中排名第 430 位。

累计安装
118
累计下载
3,345
星标
3
全站排名
#3,377
全站前 67% · 「开发编程」前 75%
平台累计安装累计下载星标评论
ClawHub ↗1073,3453-
SkillHub ↗1183,3093—

各平台的计数口径不同,统计时间不一致。

这个技能是做什么的

内容涵盖选择正确的应用二进制、使用 CLI 录制 Time Profiler 跟踪、导出结果和排查常见问题。录制可能需要启动应用或附加到运行进程,操作前应确认目标进程及输出路径。

资料发布于 2026-10-29

可以用来做什么

  • 定位 macOS/iOS 原生应用的性能瓶颈
  • 采集并查看 Time Profiler 跟踪

什么时候用

  • 需要分析原生应用性能或调用栈时

示例提示词

以下是根据技能文档生成的示例,不代表实际运行结果。

说明如何选择正确的应用进程并规划一次只读性能采样;不要启动应用或录制跟踪。

月度数据趋势

累计下载3,345
2,1612,7973,4332026-03 · 累计下载 2,2492026-05 · 累计下载 2,6942026-06 · 累计下载 2,8372026-07 · 累计下载 3,0922026-08 · 累计下载 3,2202026-09 · 累计下载 3,34526-0326-09
星标3
2342026-03 · 星标 32026-05 · 星标 32026-06 · 星标 32026-07 · 星标 32026-08 · 星标 32026-09 · 星标 326-0326-09

2026-09 起统计方法调整:同名技能按作者分别统计,并覆盖全部技能。图中虚线为调整前的月份,与之后的数据不直接比较,也不计算跨越调整的增长。

月份累计下载环比星标
2026-093,345—3
2026-083,220+4.1%3
2026-073,092+9.0%3
2026-062,837+5.3%3
2026-052,694—3
2026-032,249—3

SKILL.md 原文

以下是作者发布的原始文件,按纯文本显示,本站未做修改或审核;其中的链接不可点击,命令请核实后再运行。抓取于 2026-10-23。

3.7 KB · ClawHub v1.0.0
---
name: instruments-profiling
description: Use when profiling native macOS or iOS apps with Instruments/xctrace. Covers correct binary selection, CLI arguments, exports, and common gotchas.
metadata:
  short-description: Instruments profiling for macOS/iOS apps
---

# Instruments Profiling (macOS/iOS)

Use this skill when the user wants performance profiling or stack analysis for native apps.
展开全部(共 90 行)
Focus: Time Profiler, `xctrace` CLI, and picking the correct binary/app instance.

## Quick Start (CLI)

- List templates: `xcrun xctrace list templates`
- Record Time Profiler (launch):
  - `xcrun xctrace record --template 'Time Profiler' --time-limit 60s --output /tmp/App.trace --launch -- /path/To/App.app`
- Record Time Profiler (attach):
  - Launch app yourself, get PID, then:
  - `xcrun xctrace record --template 'Time Profiler' --time-limit 60s --output /tmp/App.trace --attach <pid>`
- Open trace in Instruments:
  - `open -a Instruments /tmp/App.trace`

Note: `xcrun xctrace --help` is not a valid subcommand. Use `xcrun xctrace help record`.

## Picking the Correct Binary (Critical)

**Gotcha: Instruments may profile the wrong app** (e.g., one in `/Applications`) if LaunchServices resolves a different bundle.
Use these rules:

- Prefer direct binary path for deterministic launch:
  - `xcrun xctrace record ... --launch -- /path/App.app/Contents/MacOS/App`
- If launching `.app`, ensure it’s the intended bundle:
  - `open -n /path/App.app`
  - Verify with `ps -p <pid> -o comm= -o command=`
- If both `/Applications/App.app` and a local build exist, explicitly target the local build path.
- After launch, confirm the process path before trusting the trace.

## Command Arguments (xctrace)

- `--template 'Time Profiler'`: template name from `xctrace list templates`.
- `--launch -- <cmd>`: everything after `--` is the target command (binary or app bundle).
- `--attach <pid|name>`: attach to running process.
- `--output <path>`: `.trace` output. If omitted, file saved in CWD.
- `--time-limit 60s|5m`: set capture duration.
- `--device <name|UDID>`: required for iOS device runs.
- `--target-stdout -`: stream launched process stdout to terminal (useful for CLI tools).

## Exporting Stacks (CLI)

- Inspect trace tables:
  - `xcrun xctrace export --input /tmp/App.trace --toc`
- Export raw time-profile samples:
  - `xcrun xctrace export --input /tmp/App.trace --xpath '/trace-toc/run[@number="1"]/data/table[@schema="time-profile"]' --output /tmp/time-profile.xml`
- Post-process in a script (Python/Rust) to aggregate stacks.

## Instruments UI Workflow

- Template: Time Profiler
- Use “Record” and capture the slow path (startup vs steady-state)
- Call Tree tips:
  - Hide System Libraries
  - Invert Call Tree
  - Separate by Thread
  - Focus on hot frames and call counts

## Gotchas & Fixes

- **Wrong app profiled**: LaunchServices resolves installed app instead of local build.
  - Fix: use direct binary path or `--attach` with known PID.
- **No samples / empty trace**: App exits quickly or never hits work.
  - Fix: longer capture, trigger workload during recording.
- **Privacy prompts**: `xctrace` may need Developer Tools permission.
  - Fix: System Settings → Privacy & Security → Developer Tools → allow Terminal/Xcode.
- **Large XML exports**: `time-profile` exports are huge.
  - Fix: filter with XPath and aggregate offline; don’t print to terminal.

## iOS Specific Notes

- Device: use `xcrun xctrace list devices` and `--device <UDID>`.
- Launch via Xcode if needed; attach with `xctrace --attach`.
- Ensure debug symbols for meaningful stacks.

## Verification Checklist

- Confirm trace process path matches target build.
- Confirm stacks show expected app frames.
- Capture covers the slow operation (startup/refresh). 
- Export stacks for automated diffing if optimizing.

「开发编程」分类下的热门技能

Peter Steinberger 的其他技能

数据月份:2026-09 · 下载/星标/安装数聚合自公开技能注册库(ClawHub、SkillHub),按月更新。口径说明见数据方法。