跳到正文
Skillpedia
移动应用7.2k · #13340

performance-profiling

它能做什么

这个技能指导智能体诊断 iPhone、iPad 和 Mac 应用的性能问题。适合需要找出卡顿、内存增长、启动缓慢或耗电过快原因的开发者。

适用场景

  • ✓iPhone、iPad 或 Mac 应用卡住或出现卡顿的时候。
  • ✓内存持续增长,或应用因内存耗尽而崩溃的时候。
  • ✓应用启动缓慢或耗电很快的时候。

技能链接

https://github.com/MengTo/Skills/blob/main/agent-skills/codex/performance-profiling/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/MengTo/Skills/blob/main/agent-skills/codex/performance-profiling/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我的 iPhone 应用在打开菜单时会卡顿一秒。请找出原因,并给出修复建议。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会针对问题选择合适的性能分析方法,读取测量数据,然后进行有针对性的修复。之后,它会用真实测量来检查这项改动。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Performance 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

  1. Identify the performance category from the user report, traces, logs, or code path.
  2. Read only the matching reference file unless the issue is broad or unclear.
  3. Prefer real device profiling with a Release build and representative data.
  4. Inspect the code path named by the profile before proposing a fix.
  5. Apply the smallest targeted fix that addresses the measured bottleneck.
  6. 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_signpost markers 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 thr
常见问题

它使用哪些工具?

Apple 的 Instruments、Xcode 诊断和 MetricKit,以及用于测量自定义工作的 signpost 标记。

它只是猜测修复方案吗?

不是。技能要求智能体用真实测量来验证每一项改动。

它涵盖 App Store 上架前的检查吗?

涵盖。它包括发布前的性能审核。

详情

作者的原始描述

Guide performance profiling for Apple platform apps with Instruments, Xcode diagnostics, and MetricKit. Use when investigating app hangs, stutters, high CPU, memory leaks, memory growth, OOM crashes, slow launch, battery drain, thermal issues, App Store performance readiness, or when adding os_signpost and measurement hooks.

repo: MengTo/Skills

热度

GitHub 星标
7.2k
排名
#13340
许可证
MIT
更新时间
2026/11/1

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能