Chuyển đến nội dung
Skillpedia
Lập trình chung7.4k · #13237

native-app-performance

Skill này làm gì

Skill này ghi một bản trace Time Profiler bằng các công cụ dòng lệnh của Apple, rồi xếp hạng các điểm nóng mà không cần mở Instruments. Dành cho lập trình viên tìm hiểu hành vi chậm của ứng dụng gốc.

Khi nào nên dùng

  • ✓Khi một ứng dụng Mac hoặc iOS gốc chạy chậm và bạn muốn tìm đoạn mã nóng.
  • ✓Khi bạn muốn một hồ sơ được ghi từ dòng lệnh thay vì trong ứng dụng.
  • ✓Khi một bản trace trả về stack rỗng và hành động chậm phải được ghi lại lần nữa.

Liên kết skill

https://github.com/steipete/agent-scripts/blob/main/skills/native-app-performance/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/steipete/agent-scripts/blob/main/skills/native-app-performance/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

“Ghi một bản trace hiệu năng 90 giây khi tôi làm hành động chậm trong ứng dụng, rồi liệt kê các điểm nóng hàng đầu.”

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

Cách hoạt động

Agent ghi bản trace bằng công cụ xctrace, trích xuất các mẫu thời gian, tìm địa chỉ nạp và xếp hạng các hàm nóng nhất bằng các script đi kèm.

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.

Native App Performance (CLI-only)

Goal: record Time Profiler via xctrace, extract samples, symbolicate, and propose hotspots without opening Instruments.

Quick start (CLI)

  1. Record Time Profiler (attach):
# Start app yourself, then attach
xcrun xctrace record --template 'Time Profiler' --time-limit 90s --output /tmp/App.trace --attach <pid>
  1. Record Time Profiler (launch):
xcrun xctrace record --template 'Time Profiler' --time-limit 90s --output /tmp/App.trace --launch -- /path/App.app/Contents/MacOS/App
  1. Extract time samples:
scripts/extract_time_samples.py --trace /tmp/App.trace --output /tmp/time-sample.xml
  1. Get load address for symbolication:
# While app is running
vmmap <pid> | rg -m1 "__TEXT" -n
  1. Symbolicate + rank hotspots:
scripts/top_hotspots.py --samples /tmp/time-sample.xml \
  --binary /path/App.app/Contents/MacOS/App \
  --load-address 0x100000000 --top 30

Workflow notes

  • Always confirm you’re profiling the correct binary (local build vs /Applications). Prefer direct binary path for --launch.
  • Ensure you trigger the slow path during capture (menu open/close, refresh, etc.).
  • If stacks are empty, capture longer or avoid idle sections.
  • xcrun xctrace help record and xcrun xctrace help export show correct flags.

Included scripts

  • scripts/record_time_profiler.sh: record via attach or launch.
  • scripts/extract_time_samples.py: export time-sample XML from a trace.
  • scripts/top_hotspots.py: symbolicate and rank top app frames.

Gotchas

  • ASLR means you must use the runtime __TEXT load address from vmmap.
  • If using a new build, update the --binary path; symbols must match the trace.
  • CLI-only flow: no need to open Instruments if stacks are symbolicated via atos.
Câu hỏi thường gặp

Tôi có cần mở Instruments không?

Không. Skill thực hiện việc profiling từ dòng lệnh mà không mở Instruments.

Vì sao bản trace có thể sai?

Skill cảnh báo có thể đã đo nhầm một bản sao khác của ứng dụng, nên cần nhắm đúng đường dẫn file nhị phân.

Nếu các stack rỗng thì sao?

Skill nói hãy ghi lâu hơn hoặc tránh các đoạn không hoạt động.

Chi tiết

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

Native app performance: xctrace, Time Profiler, traces, hotspots.

repo: steipete/agent-scripts

Độ phổ biến

Sao GitHub
7.4k
Vị trí xếp hạng
#13237
Giấy phép
MIT
Cập nhật
30/10/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ự