Chuyển đến nội dung
Skillpedia
Ứng dụng di động7.2k · #13340

performance-profiling

Skill này làm gì

Skill này hướng dẫn agent chẩn đoán các vấn đề hiệu năng trong ứng dụng iPhone, iPad và Mac. Nó dành cho lập trình viên cần tìm nguyên nhân gây đơ, bộ nhớ tăng, khởi động chậm hoặc hao pin.

Khi nào nên dùng

  • ✓Khi một ứng dụng iPhone, iPad hoặc Mac bị đơ hoặc giật.
  • ✓Khi bộ nhớ tiếp tục tăng hoặc ứng dụng bị crash vì hết bộ nhớ.
  • ✓Khi ứng dụng mở chậm hoặc tiêu hao pin nhanh.

Liên kết skill

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

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/MengTo/Skills/blob/main/agent-skills/codex/performance-profiling/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Ứng dụng iPhone của tôi bị đơ một giây khi tôi mở menu. Hãy tìm nguyên nhân và đề xuất cách sửa.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent chọn đúng phương pháp đo cho vấn đề, đọc các số liệu, rồi áp dụng một bản sửa có mục tiêu. Sau đó nó kiểm tra thay đổi bằng số đo thật.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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
Câu hỏi thường gặp

Skill dùng những công cụ nào?

Instruments của Apple, chẩn đoán trong Xcode và MetricKit, cùng với signpost để đo công việc tùy chỉnh.

Nó có chỉ đoán cách sửa không?

Không. Skill yêu cầu agent kiểm chứng mỗi thay đổi bằng số đo thật.

Có bao gồm việc sẵn sàng lên App Store không?

Có. Skill có một bước kiểm tra hiệu năng trước khi phát hành.

Chi tiết

Mô tả gốc của tác giả

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

Độ phổ biến

Sao GitHub
7.2k
Vị trí xếp hạng
#13340
Giấy phép
MIT
Cập nhật
1/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự