Swift version: 5.2
All performance tests in Xcode can have baselines attached to them, which are stored results that you consider representative of your app’s performance as things stand. The baseline is useful because it gives Xcode a measuring point for all other changes you make: if you accidentally change your code so that it runs slower, Xcode will consider your performance test to be a failure.
To set a baseline for a performance test, first make sure it has been run at least once. You should see a gray bar next to the test saying “No baseline average for time”, but if you click the gray diamond to the left of your test a balloon appears offering more information.
To set a baseline, click the Set Baseline button inside that balloon. You’ll see a “Max STDDEV” field set to 10% by default – that’s how much variance Xcode allows before it considers a test to have failed, but you can change it however you want. Broadly speaking, extremely fast code should have a higher standard deviation allowance than slower code, only because extremely fast code is likely to show more variance due to system conditions.
SPONSORED Ever ask for help and your reviewer immediately notices issues you missed? Fernando Olivares is a 10-year veteran from Big Nerd Ranch and Lambda School who can help hone your app building skills, and he's just launched a new book that does just that – use the code "hacking" to save $5!
Available from iOS
This is part of the Swift Knowledge Base, a free, searchable collection of solutions for common iOS questions.
Link copied to your pasteboard.