Community研究與資料分析github.com

steipete/native-app-performance

原生應用程式效能分析:xctrace、Time Profiler、追蹤、熱點。

native-app-performance 是什麼?

此技能提供了一個純命令列的工作流程,用於記錄和分析 iOS/macOS 原生應用程式的效能。它利用 `xctrace` 工具附加到或啟動應用程式,記錄 Time Profiler 追蹤,然後從追蹤中提取時間樣本,對其進行符號化,並找出最耗費 CPU 的熱點函數,全程無需開啟 Instruments 圖形化介面。對於需要在 CI/CD 管道或遠端伺服器上進行自動化效能測試,或偏好命令列工具的開發者來說,這項技能非常有用。它支援 macOS 平台,並包含 `extract_time_samples.py` 和 `top_hotspots.py` 等輔助腳本,以簡化分析流程。使用此技能時需注意 ASLR 位址隨機化,並確保二進位檔案路徑與追蹤中使用的符號相匹配。

相容平台~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.

相關技能