In May, Jordan Rose added a Swift flag for emitting warnings whenever a function takes longer than some threshold to compile. You can leave this flag enabled in your project, and it will warn you whenever any slow functions are added to the project.
[…]
Add two flags:
-Xfrontend
and-warn-long-function-bodies=100
, where 100 is the number of milliseconds you’d like the warning threshold to be
Previously: Exponential Time Complexity in the Swift Type Checker.
Update (2016-12-06): Simone Manganelli:
Haven’t seen anyone warn about this, but merely enabling these debugging flags can cause compile time to drastically increase.