Przejdź do treści
Biblioteka skilli
Programowanie · Analiza

swift-performance-pro

/swift-performance-pro

Diagnozuje wydajność aplikacji Swift: koszt renderowania SwiftUI, cykle silnych referencji, czas startu i pomiary w Instruments.

Licencja
MIT
Ostatnia zmiana repozytorium
18.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 18.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Diagnozuje wydajność aplikacji Swift: koszt renderowania SwiftUI, cykle silnych referencji, czas startu i pomiary w Instruments.

Oryginalny opis (EN)

Use when diagnosing or fixing performance — SwiftUI render cost, memory and retain cycles, slow lists, launch time, and using Instruments.

Jak działa

  1. When to use
  2. Core principles
  3. SwiftUI render cost
  4. Lists
  5. Memory & retain cycles
  6. Off the main actor
  7. Launch time
  8. Common mistakes checklist
  9. Output format (when reviewing)
Sekcje z nagłówków SKILL.md, w oryginale · 91 linii, 415 słów
Podgląd SKILL.md
---
name: swift-performance-pro
description: Use when diagnosing or fixing performance — SwiftUI render cost, memory and retain cycles, slow lists, launch time, and using Instruments.
license: MIT
metadata:
  author: Lax Rajpurohit
  version: "1.0.0"
---

# Swift Performance Pro

Find and fix performance problems with evidence, not guesses. Measure first.

## When to use

- Janky scrolling, slow launch, high memory, or battery drain.
- Reviewing code for performance regressions.
- Planning an Instruments session.

Trigger: `/swift-performance-pro`.

## Core principles

- Measure before optimizing — use Instruments (Time Profiler, Allocations, SwiftUI,
  Leaks), not intuition.
- Keep SwiftUI `body` cheap and pure; recomputation is frequent.
- Do heavy work off the main actor.
- Don't optimize what you haven't proven is hot.

## SwiftUI render cost

Keep `body` free of side effects and heavy compute.

❌ Sorting on every render
```swift
var body: some View {
    List(items.sorted { $0.date > $1.date }) { Row($0) }   // re-sorts each pass
}
```
✅ Sort once in the model
```swift
// model exposes already-sorted `items`
var body: some View { List(model.items) { Row($0) } }
```

Narrow observation so unrelated changes don't redraw everything. Split big views into
small subviews so SwiftUI can diff precisely.

## Lists

- `LazyVStack`/`List` for long content, not eager `VStack` in a `ScrollView`.
- Stable `Identifiable` IDs — index-based identity forces full rebuilds.
- Avoid `AnyView` in row builders; it defeats SwiftUI's diffing.

## Memory & retain cycles

❌ Strong self capture in a stored closure
```swift
manager.onUpdate = { self.refresh() }   // cycle: manager → closure → self
```
✅
```swift
manager.onUpdate = { [weak self] in self?.refresh() }
```
Verify `deinit` runs. Use Instruments → Leaks / Allocations to confirm.

## Off the main actor

❌
```swift
let image = UIImage(data: hugeData)   // decode on main → dropped frames
```
✅
```swift
let image = await Task.detached { UIImage(data: hugeData) }.value
```
Downsample large images to the display size instead of loading full-resolution.

## Launch time

- Defer non-critical work out of `init`/`onAppear`; load it in `.task`.
- Avoid synchronous disk/network on the launch path.
- Audit with Instruments → App Launch.

## Common mistakes checklist

- [ ] Sorting/filtering/heavy compute inside `body`.
- [ ] Eager `VStack` where `LazyVStack`/`List` is needed.
- [ ] Index-based identity forcing full list rebuilds.
- [ ] `AnyView` in hot row builders.
- [ ] Strong `self` in stored closures (retain cycle).
- [ ] Image decode / disk / network on the main actor or launch path.
- [ ] Optimizing without an Instruments trace proving the hotspot.

## Output format (when reviewing)

Per issue: file:line, the cost, before/after, and which Instrument confirms it. Lead with
main-thread blockers.

Wersje

W bazie nie ma innych skilli o nazwie swift-performance-pro.

Migawka bazy z 13.11.2026 · wersja paczki dd189bb0eb07 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100swift-performance-optimization
    Profiluje wolne ekrany SwiftUI, optymalizuje listy, odciąża wątek główny i poprawia pamięć oraz procesor przy użyciu Instruments.
  • 100memory-leak-diagnosis
    Pomaga badać wzrost pamięci, cykle retain, wycieki w Instruments, problemy z anulowaniem Task i ARC w aplikacjach Swift 6.
  • 100swiftui-pro
    Pisze, przegląda i refaktoryzuje SwiftUI dla iOS 26 i Swift 6: @Observable, NavigationStack, układ, wydajność i dostępność.
  • 100axiom-performance
    Diagnozuje problemy wydajności aplikacji Apple, gdy działa wolno, rośnie pamięć lub szybko schodzi bateria: wycieki pamięci, profilowanie, Instruments, cykle retain i optymalizacja.
  • 100axiom-performance
    Diagnozuje problemy wydajności aplikacji Apple, gdy działa wolno, rośnie pamięć lub szybko schodzi bateria: wycieki pamięci, profilowanie, Instruments, cykle retain i optymalizacja.
  • 100swiftui-performance-audit
    Diagnozuje wydajność SwiftUI na podstawie kodu i dowodów: renderowanie, przewijanie, aktualizacje, CPU, pamięć, obrazy, układ i animacje, przed pomiarem w Instruments.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.