{"id":19046,"date":"2017-09-28T16:30:26","date_gmt":"2017-09-28T20:30:26","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=19046"},"modified":"2018-04-29T00:25:07","modified_gmt":"2018-04-29T04:25:07","slug":"measuring-swift-compile-times-in-xcode-9","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2017\/09\/28\/measuring-swift-compile-times-in-xcode-9\/","title":{"rendered":"Measuring Swift Compile Times in Xcode 9"},"content":{"rendered":"<p><a href=\"https:\/\/www.jessesquires.com\/blog\/measuring-compile-times-xcode9\/\">Jesse Squires<\/a>:<\/p>\n<blockquote cite=\"https:\/\/www.jessesquires.com\/blog\/measuring-compile-times-xcode9\/\"><p>As mentioned, after you add these flags you will start getting warnings. Keep in mind that if the threshold is too low, for example 10ms, then you will get <strong>a ton<\/strong> of warnings that cannot be fixed. Experiment with these threshold values and adjust as needed. I suggesting starting at <code>200<\/code> and tuning from there. If your code base is large, it might make more sense to use a higher value for your project (say <code>500<\/code>) and try to decrease it over time. Otherwise, you&rsquo;ll be spending <strong>a lot<\/strong> of time trying to get all functions and expressions to compile in under 200ms. Also, I recommend setting these flags only for <code>DEBUG<\/code> build configurations.<\/p><p>There are two common scenarios where Xcode will start emitting warnings with these flags: (1) very complex expressions or functions, and (2) expressions that omit explicit types and rely on <a href=\"https:\/\/developer.apple.com\/library\/content\/documentation\/Swift\/Conceptual\/Swift_Programming_Language\/Types.html\">type inference<\/a>. To silence the warnings &mdash; and thus improve compile times &mdash; try breaking up expressions into smaller steps with intermediate variables, and adding explicit types to variable declarations and closure parameters.<\/p><\/blockquote>\n<p>Previously: <a href=\"https:\/\/mjtsai.com\/blog\/2016\/12\/05\/guarding-against-long-swift-compiles\/\">Guarding Against Long Swift Compiles<\/a>.<\/p>\n\n<p>Update (2018-04-29): See also: <a href=\"https:\/\/twitter.com\/krzyzanowskim\/status\/988319426993885184\">Marcin Krzyzanowski<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<p>Jesse Squires: As mentioned, after you add these flags you will start getting warnings. Keep in mind that if the threshold is too low, for example 10ms, then you will get a ton of warnings that cannot be fixed. Experiment with these threshold values and adjust as needed. I suggesting starting at 200 and tuning [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2018-04-29T04:25:09Z","apple_news_api_id":"d7d5e43b-8145-4e12-b403-4271c0f8a46a","apple_news_api_modified_at":"2018-04-29T04:25:10Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/A19XkO4FFThK0A0JxwPikag","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[255,71,901,226],"class_list":["post-19046","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-compiler","tag-programming","tag-swift-programming-language","tag-xcode"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/19046","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=19046"}],"version-history":[{"count":2,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/19046\/revisions"}],"predecessor-version":[{"id":21369,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/19046\/revisions\/21369"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=19046"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=19046"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=19046"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}