본문으로 건너뛰기
Skillpedia
일반 코딩7.4k · #13233

instruments-profiling

하는 일

이 스킬은 네이티브 Apple 앱의 Time Profiler 추적 기록을 만들어 Instruments에서 여는 방법을 보여 줍니다. 느리거나 무거운 네이티브 앱을 조사하는 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓macOS나 iOS 앱이 느려서 시간이 어디에 쓰이는지 봐야 할 때.
  • ✓다른 앱 복사본이 아니라 특정 앱 빌드의 추적 기록이 필요할 때.
  • ✓앱 성능을 명령줄에서 기록하고 싶을 때.

스킬 링크

https://github.com/steipete/agent-scripts/blob/main/skills/instruments-profiling/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/steipete/agent-scripts/blob/main/skills/instruments-profiling/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“프로젝트를 열면 Mac 앱이 느려요. 성능 추적을 기록해서 시간이 어디에 많이 쓰이는지 보여 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트는 xctrace 명령줄 도구로 올바른 앱 바이너리에 연결해 추적을 기록하고, 결과를 Instruments에서 열어 스택을 분석합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Instruments Profiling (macOS/iOS)

Use this skill when the user wants performance profiling or stack analysis for native apps. 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.
자주 묻는 질문

잘못된 앱을 프로파일링할 수 있는 이유는 무엇인가요?

macOS가 다른 앱 복사본을 선택할 수 있으므로, 스킬은 정확한 바이너리 경로를 지정하도록 권장한다고 경고합니다.

기록은 얼마나 걸리나요?

예시는 60초 같은 시간 제한을 사용합니다.

이미 실행 중인 앱에 연결할 수 있나요?

네. 앱을 실행한 뒤 프로세스 ID에 연결하는 방법을 설명합니다.

상세 정보

작성자의 원본 설명

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

repo: steipete/agent-scripts

인기도

GitHub 스타
7.4k
순위
#13233
라이선스
MIT
업데이트
2026. 10. 30.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬