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
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.
About This Article
Swift developers had to piece together performance testing using separate tools like Instruments and DTrace because the language lacked a unified benchmarking framework. There was no standard way to measure multi-platform metrics or integrate performance checks into CI pipelines.
Ordo One built the Benchmark package as a SwiftPM command plugin that handles performance testing automatically. It tracks over 20 metrics including CPU time, memory allocation, syscalls, and ARC retain/release counts on both macOS and Linux.
Foundation, SwiftPM, SwiftNIO, and Google Flatbuffers all adopted the package. Teams now run automated regression checks on pull requests and monitor performance consistently within their CI pipelines.