Introducing the Benchmark Package: Complementing Unit Tests with Performance Checks
In the world of software development, the old adage “make it work, make it right, make it fast” serves as a guiding principle for creating robust, efficient applications. This journey starts with ensuring that our code functions as intended, a task where unit and integration testing have proven indispensable. However, ensuring functionality is only part of the equation. The true measure of an application’s excellence extends into its performance - how fast and efficiently it operates under various conditions. Herein lies the critical but often overlooked third step: making it fast.
The Swift Benchmark package, a new open-source tool developed due to the lack of suitable multi-platform benchmarking solutions, integrates performance testing into Swift’s ecosystem, emphasising the importance of speed alongside functionality in software development.
Designed as a SwiftPM command plugin, it automates performance validation with a command (swift package benchmark
) and supports a wide range of metrics like CPU usage, memory allocation, and system calls, crucial for optimising resource-constrained environments.
It enables developers to write benchmarks, such as for Foundation.Date
or the Histogram
package, with customisable configurations and supports workflows like automated pull request regression checks and manual baseline comparisons.
The package offers human-readable table output, various export formats for analysis, and integration with tools like Instruments, with adoption by major projects like Swift Foundation and SwiftNIO.
Category:
Tag:
Year: