From apple-docs
Profile application performance using Instruments - find CPU bottlenecks, memory leaks, and more.
npx claudepluginhub briannadoubt/claude-marketplace --plugin apple-docsThis skill uses the workspace's default tool permissions.
Profile application performance using Instruments - find CPU bottlenecks, memory leaks, and more.
Provides Ktor server patterns for routing DSL, plugins (auth, CORS, serialization), Koin DI, WebSockets, services, and testApplication testing.
Conducts multi-source web research with firecrawl and exa MCPs: searches, scrapes pages, synthesizes cited reports. For deep dives, competitive analysis, tech evaluations, or due diligence.
Provides demand forecasting, safety stock optimization, replenishment planning, and promotional lift estimation for multi-location retailers managing 300-800 SKUs.
Profile application performance using Instruments - find CPU bottlenecks, memory leaks, and more.
# See all profiling templates
xcrun xctrace list templates
Common templates:
# Find your app's PID
pgrep -l MyApp
# Profile with Time Profiler for 10 seconds
xcrun xctrace record \
--template "Time Profiler" \
--attach $(pgrep MyApp) \
--time-limit 10s \
--output /tmp/profile.trace
# Profile from launch
xcrun xctrace record \
--template "Time Profiler" \
--launch -- /path/to/MyApp.app/Contents/MacOS/MyApp \
--time-limit 30s \
--output /tmp/launch.trace
# First, get the app's PID on the simulator
xcrun simctl spawn booted launchctl list | grep myapp
# Profile simulator process
xcrun xctrace record \
--template "Time Profiler" \
--device "iPhone 16" \
--attach com.example.myapp \
--time-limit 10s \
--output /tmp/profile.trace
# Open trace file in Instruments GUI
open /tmp/profile.trace
# List available instruments in trace
xcrun xctrace export --input /tmp/profile.trace --toc
# Export to XML
xcrun xctrace export --input /tmp/profile.trace --output /tmp/export.xml
# Time Profiler - see where CPU time is spent
xcrun xctrace record \
--template "Time Profiler" \
--attach $(pgrep MyApp) \
--time-limit 30s \
--output /tmp/cpu.trace
Look for:
# Allocations - track all memory allocations
xcrun xctrace record \
--template "Allocations" \
--attach $(pgrep MyApp) \
--time-limit 30s \
--output /tmp/memory.trace
# Leaks - find memory leaks
xcrun xctrace record \
--template "Leaks" \
--attach $(pgrep MyApp) \
--time-limit 60s \
--output /tmp/leaks.trace
# System Trace for UI hangs
xcrun xctrace record \
--template "System Trace" \
--attach $(pgrep MyApp) \
--time-limit 10s \
--output /tmp/system.trace
# Energy profiling (device recommended)
xcrun xctrace record \
--template "Energy Log" \
--attach $(pgrep MyApp) \
--time-limit 60s \
--output /tmp/energy.trace
For more complex analysis, use Instruments.app:
# Open Instruments
open -a Instruments
# Or with a specific template
open -a Instruments --args -t "Time Profiler"
# Check memory usage
ps aux | grep MyApp | awk '{print $6/1024 " MB"}'
# Detailed memory (macOS)
vmmap $(pgrep MyApp) | tail -5
# Watch CPU usage
top -pid $(pgrep MyApp) -l 5
# Check file handles
lsof -p $(pgrep MyApp) | wc -l
--template exactly as shown by xctrace list templatesFor integrated profiling with parsed results:
instruments_profile - Profile and get parsed summarylist_instruments_templates - List available templatesThese tools handle the complexity of finding the right process and return structured summaries instead of raw trace files.