Community研究与数据分析github.com

steipete/native-app-performance

原生应用性能分析:xctrace、Time Profiler、迹线、热点代码。

native-app-performance 是什么?

该技能为原生应用开发者提供了一套纯命令行的工作流,用于记录、提取和符号化 iOS/macOS 应用的 Time Profiler 迹线,并自动识别热点代码,而无需打开 Instruments 图形界面。它通过 `xcrun xctrace` 命令附加到或启动目标进程进行采样,使用附带脚本提取时间样本为 XML 格式,然后利用 `atos` 工具对调用栈进行符号化,最终按耗时排序输出排名靠前的热点帧。支持任意可运行 `xctrace` 和 `vmmap`(macOS)的平台,特别适合持续集成或自动化性能回归测试场景。用户需注意 ASLR 导致的地址偏移,必须从 `vmmap` 获取运行时 `__TEXT` 加载地址,并确保符号文件与迹线匹配。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/steipete/agent-scripts/tree/main/skills/native-app-performance

Installed? Explore more 研究与数据分析 skills: affaan-m/uspto-database, affaan-m/scholar-evaluation, affaan-m/literature-review · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

原生应用性能(仅限命令行)

目标:通过 xctrace 记录 Time Profiler,提取样本、符号化并分析热点代码,无需打开 Instruments。

快速开始(命令行)

  1. 录制 Time Profiler(附加到进程):
# 自行启动应用,然后附加
xcrun xctrace record --template 'Time Profiler' --time-limit 90s --output /tmp/App.trace --attach <pid>
  1. 录制 Time Profiler(启动应用):
xcrun xctrace record --template 'Time Profiler' --time-limit 90s --output /tmp/App.trace --launch -- /path/App.app/Contents/MacOS/App
  1. 提取时间样本:
scripts/extract_time_samples.py --trace /tmp/App.trace --output /tmp/time-sample.xml
  1. 获取符号化所需的加载地址:
# 应用运行时执行
vmmap <pid> | rg -m1 "__TEXT" -n
  1. 符号化 + 热点排名:
scripts/top_hotspots.py --samples /tmp/time-sample.xml \
  --binary /path/App.app/Contents/MacOS/App \
  --load-address 0x100000000 --top 30

工作流注意事项

  • 始终确认正在分析的二进制文件是正确的(本地构建 vs /Applications)。优先使用 --launch 指定直接的二进制路径。
  • 确保在捕获期间触发了慢路径(菜单开/关、刷新等)。
  • 如果调用栈为空,请延长捕获时间或避免捕获空闲段。
  • xcrun xctrace help record 和 xcrun xctrace help export 显示正确的标志。

包含的脚本

  • scripts/record_time_profiler.sh:通过附加或启动方式录制。
  • scripts/extract_time_samples.py:从迹线导出时间样本 XML。
  • scripts/top_hotspots.py:符号化并按排名显示顶层应用帧。

注意事项

  • ASLR 要求必须使用来自 vmmap 的运行时 __TEXT 加载地址。
  • 如果使用新版本构建,请更新 --binary 路径;符号必须与迹线匹配。
  • 仅命令行工作流:如果通过 atos 符号化调用栈,无需打开 Instruments。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

steipete/agent-transcript

GitHub PR/issue agent transcripts: redact, preview, and insert safely.

steipete/beeper

Beeper cache: contact hints, room lookup, WhatsApp/iMessage traces, FTS.

steipete/browser-use

Existing Chrome automation: Chrome plugin first, mcporter fallback.

steipete/clawsweeper-status

ClawSweeper status: URLs, workflow health, active workers, ops snapshot.

steipete/clickclack

ClickClack ops: chat app, Hetzner deploy, DNS/docs/app, Docker rollout.

steipete/cloudflare-registrar

Cloudflare Registrar: domain availability, prices, registration via mcporter.

steipete/codex-debugging

Codex debugging: codex-rs core/tui/exec/cli/app-server/config.

steipete/create-cli

CLI UX/spec: args, flags, help, output, errors, config, dry-run.

steipete/discord-clawd

Discord-backed OpenClaw agent/session relay; not archive search.

steipete/domain-dns-ops

DNS/domain ops: registrars, zones, redirects, DNS/HTTP verify, manager truth.

steipete/frontend-design

Frontend UI: pages, apps, components, polished non-generic design.

steipete/github-author-context

GitHub contributor context: identity, activity, trust, company/team signal.

steipete/github-cache-hygiene

GitHub quota/cache hygiene: gh, ghx, xcache, gitcrawl, mirrors, limits.

steipete/github-deep-review

GitHub deep review: bugs, PRs, best fix, stale-or-real, read code first.

steipete/github-project-triage

GitHub issue/PR triage: queues, CI, blockers, risk, proof, next actions.

steipete/hopper-debugger

Hopper debugging: macOS/iOS binaries, ObjC/Swift symbols, dyld, LLDB.

steipete/instruments-profiling

Instruments/xctrace profiling: macOS/iOS traces, binaries, args, exports.

steipete/mac-maintenance

Mac upkeep: brew update/upgrade, pull clean repos, empty Trash.

steipete/maintainer-orchestrator

Open-source maintainer orchestration: Codex app workers, work recovery, dependencies, vision, releases.

steipete/markdown-converter

Markdown conversion: PDF, Office, HTML, data, OCR, audio, ZIP, YouTube.

相关技能