Optimization checklist
Before doing any optimization and performance measurement, you should follow these steps:
Enable the Release mode: The Swift compiler does a lot of code optimization and improves performance in the Release mode. To enable the Release mode go to Product | Scheme | Edit Scheme | Run, select the Info tab, and select Release in the Build Configuration setting.
Disable safety checks: Disabling safety checks could improve application performance; but as its name suggests, it affects safety and disabling is not 100-percent safe and should be applied carefully. An example of a safety check Swift does is checking array bounds before accessing the memory. If you disable safety checks Swift won't do that.
Disabling safety checks is a Swift Compiler – Code Generation setting that is available in the target Build Settings. To disable safety checks select Project | Build Settings, then search for the Disable Safety Checks setting and set it to Yes for the Release mode.
Enable the Fast...