Micro Benchmarking - The Art of Realizing One is Wrong
summary
Uses JMH to show that tiny Java benchmarks lie: system arraycopy vs manual copy flips winners across JDKs and CPUs, measuring clock resolution and seeing 20–100 ns timer noise, dead‑code elimination removes work unless results are returned or blackhole consume is used, loop unrolling and inlining hide costs, cache misses (L1/L2/L3) blow times from tens to hundreds of ns, allocation churn dominates some results, and warmup/tiers produce different compiled code — use JMH, perf and async‑profiler and validate with real production data and escape analysis.
AI-written summary · about
chapters (11)
- 0:00Introduction and setup
- 10:16What is micro benchmarking
- 27:59First benchmark and warmup confusion
- 44:43Dead code elimination and inlining
- 1:06:43Common benchmarking mistakes
- 1:24:36Break and hardware insights
- 1:43:42Warmup and JIT unpredictability
- 2:03:19Threads and CPU scaling
- 2:20:54String concatenation myths
- 2:31:10When to use micro benchmarks
- 2:40:20Q&A and summary
related talks
38mBenchmarking Code Performance with JMH
49mHow Not to Do Benchmarking
38mYour benchmark may not guide a real application performance
54mPerformance tests and other lies
35mBenchmarking: You're Doing It Wrong
21mBenchmarking Like a Boss
39mMicro Benchmarks
43mStop Guessing and Start Measuring - Benchmarking in Practice
