Swift Performance Benchmarks
Article Summary
Joakim Hassila from Ordo One built a performance benchmarking tool that major Swift projects like Foundation, SwiftNIO, and SwiftPM are now using. If you're shipping Swift code without performance tests, you're flying blind.
The Benchmark package is an open-source SwiftPM plugin that brings the same rigor to performance testing that unit tests bring to functionality. Built by a team running high-performance trading systems, it tracks 20+ metrics from CPU time to memory leaks to syscalls, and integrates directly into CI pipelines.
Key Takeaways
- Tracks 20+ metrics: CPU, memory, syscalls, ARC retain/release, and I/O
- Automated PR checks catch regressions before merge using threshold comparisons
- Works for microsecond-level microbenchmarks and long-running complex tests
- Adopted by Swift Foundation, SwiftPM, SwiftNIO, and Google Flatbuffers
Critical Insight
Swift now has a comprehensive benchmarking framework that makes performance testing as routine as unit testing, with CI integration and support for both macOS and Linux.