Performa menjadi penting saat aplikasi tumbuh. Section ini membahas profil, benchmark dengan JMH, dan optimasi spesifik Kotlin.

# Profiling Kotlin Applications

Mengenal profiling aplikasi Kotlin: tools utama (VisualVM, async-profiler, JFR), CPU sampler, memory profiler, dan teknik step-counting untuk demo deterministik.

Buka →
# Benchmarking Fundamentals

Fundamental microbenchmark: tiga jebakan utama (JIT warmup, dead code elimination, GC pauses), aturan emas, dan demo step-counting yang deterministik.

Buka →
# JMH

Java Microbenchmark Harness: anotasi @Benchmark, @State, @Warmup, @Measurement, plugin Gradle JMH, dan simulasi runner yang menangani jebakan microbenchmark otomatis.

Buka →
# Allocation Profiling

Menemukan alokasi objek berlebih dengan profiler, escape analysis JIT, dan perbandingan strategi implementasi: String concat vs StringBuilder, Array`<Int>` vs IntArray.

Buka →
# Collection Performance

Performansi koleksi Kotlin: ArrayList vs LinkedList, HashMap vs TreeMap, pre-size dengan initialCapacity, dan tabel ringkasan Big-O.

Buka →
# Sequence Performance

Sequence vs List untuk chained operations: Sequence menang untuk koleksi besar dengan banyak operasi, List menang untuk koleksi kecil atau single pass.

Buka →
# Coroutine Performance

Performansi coroutine: lebih ringan daripada thread, pilihan dispatcher (Default, IO, Main), context switch overhead, dan aturan optimasi concurrency.

Buka →
# Memory Usage

Mengukur overhead memori: object header, primitif vs boxed, IntArray vs Array<Int>, dan string deduplication.

Buka →
# Avoiding Unnecessary Allocations

Pola mengurangi alokasi objek: StringBuilder, object reuse, value class, pooling, dan sequence untuk pipeline lazy.

Buka →
# inline Functions Performance

Mekanisme inline function, eliminasi alokasi lambda, reified type, crossinline/noinline, serta trade-off bytecode size.

Buka →
# Performance Regression Testing

Mendeteksi regression performance via benchmark CI, output JSON, baseline comparison, dan threshold warning/fail.

Buka →