
Performance Profiling
FreeDiagnose and optimize Apple app performance issues.
Free · Opens the source repo
What Performance Profiling does
The Performance Profiling skill is designed to help developers systematically identify and address performance issues in Apple platform applications. By utilizing tools such as Instruments, Xcode diagnostics, and MetricKit, this skill provides a structured approach to diagnosing problems like app hangs, high CPU usage, memory leaks, and slow launch times. It guides users through selecting the appropriate reference materials based on the specific performance issue they are facing, ensuring that they have the right information to make informed decisions.
The skill features a decision tree that directs users to the relevant reference files for various performance problems. This includes detailed guidance on using the Time Profiler for CPU-related issues, memory profiling tools for detecting leaks, and energy diagnostics for battery and thermal issues. Each reference file contains targeted strategies and metrics to measure the effectiveness of any changes made, allowing developers to verify improvements with concrete data.
The workflow outlined in the skill emphasizes the importance of profiling on actual devices and in Release configurations to obtain accurate results. It encourages developers to make the smallest necessary code changes to address identified bottlenecks, followed by re-profiling to confirm the effectiveness of these changes. Additionally, the skill includes a review checklist that covers best practices for responsiveness, memory management, launch optimization, and energy efficiency, ensuring comprehensive performance audits.
Overall, this skill is invaluable for developers looking to enhance the performance of their applications on Apple platforms, providing a clear framework for diagnosing and resolving performance-related issues effectively.
When to use it
Use this skill when you need to diagnose specific performance problems in your Apple applications, such as slow UI, memory leaks, or high CPU usage.
When not to use it
This skill may not be suitable for non-Apple platform applications or for general coding tasks unrelated to performance profiling.
What you can build with it
Investigating App Hangs
When users report app hangs or stutters, use the skill to identify the root cause and apply targeted fixes.
Memory Leak Detection
Utilize the memory profiling references to detect and resolve memory leaks that could lead to app crashes.
Pre-release Performance Audit
Before launching an app, follow the review checklist to ensure optimal performance and readiness for the App Store.
How to install Performance Profiling
View source1. Install with the skills CLI
npx skills add mengto/skills/performance-profiling --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by mengtoPerformance Profiling
Use this skill to diagnose Apple app performance issues systematically, pick the right profiling workflow, apply targeted fixes, and verify the change with real measurements.
Decision Tree
Choose the reference file before changing code:
What performance problem are you investigating?
+ App hangs, stutters, dropped frames, slow UI, high CPU
-> Read references/time-profiler.md
+ High memory, leaks, OOM crashes, growing footprint
-> Read references/memory-profiling.md
+ Slow cold launch, warm launch, resume, or time to first frame
-> Read references/launch-optimization.md
+ Battery drain, thermal throttling, background energy, network waste
-> Read references/energy-diagnostics.md
+ General "app feels slow"
-> Start with references/time-profiler.md, then references/memory-profiling.md
+ Pre-release performance audit
-> Read all reference files and use the review checklist below
Quick Reference
| Problem | Instrument / Tool | Key Metric | Reference |
|---|---|---|---|
| UI hangs over 250 ms | Time Profiler + Hangs | Hang duration, main thread stack | references/time-profiler.md |
| High CPU usage | Time Profiler | CPU percent by function, call tree weight | references/time-profiler.md |
| Memory leak | Leaks + Memory Graph | Leaked bytes, retain cycle paths | references/memory-profiling.md |
| Memory growth | Allocations | Live bytes, generation analysis | references/memory-profiling.md |
| Slow launch | App Launch | Time to first frame, pre-main, post-main | references/launch-optimization.md |
| Battery drain | Energy Log | Energy impact, CPU/GPU/network activity | references/energy-diagnostics.md |
| Thermal issues | Activity Monitor, Instruments | Thermal state transitions | references/energy-diagnostics.md |
| Network waste | Network profiler | Redundant fetches, payload size | references/energy-diagnostics.md |
Workflow
- Identify the performance category from the user report, traces, logs, or code path.
- Read only the matching reference file unless the issue is broad or unclear.
- Prefer real device profiling with a Release build and representative data.
- Inspect the code path named by the profile before proposing a fix.
- Apply the smallest targeted fix that addresses the measured bottleneck.
- Re-profile or add a repeatable measurement to confirm the improvement.
Profiling Ground Rules
- Profile on device when possible; Simulator uses host CPU and memory.
- Use Release configuration because optimizations can change hot paths.
- Reproduce with representative data, not empty databases or toy assets.
- Close unrelated apps to reduce noise during profiling.
- Keep measurements before and after the fix so the outcome is concrete.
- Add
os_signpostmarkers when a workflow needs ongoing timing visibility.
Xcode Diagnostics
Recommend relevant Scheme > Run > Diagnostics settings when they match the suspected issue:
| Setting | Use For |
|---|---|
| Main Thread Checker | UI work off the main thread |
| Thread Sanitizer | Data races and unsafe shared state |
| Address Sanitizer | Buffer overflows and use-after-free |
| Malloc Stack Logging | Allocation call stacks |
| Zombie Objects | Messages to deallocated objects |
MetricKit Hook
Suggest MetricKit for production monitoring of launch, responsiveness, memory, and diagnostics:
import MetricKit
final class PerformanceReporter: NSObject, MXMetricManagerSubscriber {
func startCollecting() {
MXMetricManager.shared.add(self)
}
func didReceive(_ payloads: [MXMetricPayload]) {
for payload in payloads {
if let launch = payload.applicationLaunchMetrics {
log("Resume time: \(launch.histogrammedResumeTime)")
}
if let responsiveness = payload.applicationResponsivenessMetrics {
log("Hang time: \(responsiveness.histogrammedApplicationHangTime)")
}
if let memory = payload.memoryMetrics {
log("Peak memory: \(memory.peakMemoryUsage)")
}
}
}
func didReceive(_ payloads: [MXDiagnosticPayload]) {
for payload in payloads {
if let hangs = payload.hangDiagnostics {
for hang in hangs {
log("Hang: \(hang.callStackTree)")
}
}
}
}
}
Review Checklist
Responsiveness:
- No synchronous work on the main thread over 100 ms.
- No file I/O or network calls on the main thread.
- Large Core Data or SwiftData fetches use background contexts.
- Images decode off the main thread.
@MainActoris limited to code that truly needs UI access.
Memory:
- No retain cycles in delegates, closures, observers, or async tasks.
- Large resources are released when no longer visible.
- Collections and caches are bounded.
autoreleasepoolis used in tight loops that create Objective-C objects.
Launch:
- No heavy work in
init()of the@main Appstruct. - Non-essential initialization is deferred.
- Dynamic frameworks are minimized where practical.
- No synchronous network calls occur during launch.
Energy:
- Background tasks use the appropriate
BGTaskSchedulerrequest type. - Location accuracy matches the product need.
- Timers use tolerance so the system can coalesce wakeups.
- Network requests are batched and cached where possible.
References
references/time-profiler.md: CPU profiling, hang detection, signpost API.references/memory-profiling.md: Allocations, Leaks, Memory Graph debugger.references/launch-optimization.md: Launch phases and cold/warm start optimization.references/energy-diagnostics.md: Battery, thermal state, and network efficiency.
Frequently asked questions about Performance Profiling
Similar skills
Heap Snapshot Analysis
Investigate V8 heap snapshots for memory issues.
VS Code Performance Workflow
Automate performance investigations in VS Code.
Memory Leak Audit
Prevent memory leaks with effective coding patterns.
CPU Profile Analysis
Analyze V8 and Chrome performance profiles for optimization.
Chat Performance Testing
Benchmark and validate chat UI performance in VS Code.
Vercel React Best Practices
Optimize your React and Next.js applications for performance.
