swift-meet-up-template-rectangle001
June Swift Meetup Recap | Performance Metrics & Measure Blocks in Swift
swift-meet-up-template-rectangle001

In our recent Utah Swift Developers Meetup, PassiveLogic’s O'Ryan Hampton lead the discussion on performance metrics & measure blocks in Swift. He discussed the tools that can be used for performance metrics and benchmarking in Swift, and provided real-time demos for both.

To kick-off the meetup, O’Ryan introduced Benchmark package, a useful Swift library used to collect performance metrics. He briefly covered its capabilities and why PassiveLogic uses it in lieu of Measure, Swift’s native performance measuring tool built into XCTest (Swift’s testing suite). Captured performance metrics help PassiveLogic determine software capabilities and prevent regression.

O'Ryan demonstrated a simple benchmarking case of “sleep" to show off how benchmarks can be run. In this demo, he guided everyone through a function he created, which sleeps for one second. He explained targeting specific benchmarks and handling outliers. He then introduced Measure, demonstrated its use to prevent app regression and provide a comparison baseline.

He then highlighted the functionalities and the flexibility Benchmark package offers for running performance tests and metrics, including how it allows functions to run multiple times to produce statistically significant results and metrics reporting. Benchmark also offers exports in multiple formats, creates customized metrics, and generates detailed reports, which include profile charts for each function call. He discussed possible naming conventions used for saving unit and performance tests when using Measure. Despite noting the absence of programmatic export capability available in Measure, he emphasized the usefulness of .CSV exports in its place.

To wrap up the evening, O’Ryan discussed some limitations to the Benchmark package including the “jemaloc” requirement. He also introduced examples of command-line support for generating graphs based on results and stressed the importance of using the same allocator as in production to avoid misleading results.

Thanks to everyone who showed up for this event and make sure to follow PassiveLogic so you don’t miss future Swift meetups! You can watch the Zoom recording here (Passcode: *R5m&Vk5).

1 / 7
Next post
Twitter%20X