Created
April 28, 2016 14:29
-
-
Save iv-mexx/938c09ff4f9861bd7827f7f8611aa8b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// This example shows a problem with swift compile times | |
// | |
// After the most recent update of PaintCode to 2.4.1, the compiletime for the generated StyleKit file exploded from | |
// few seconds to a few minutes. | |
// | |
// It seems, that they changed the generated code for creating a CGRect from using `CGRectMake` to `CGRect()` which seems to cause the problem. | |
// | |
// Below is a reduced example that showcases the problem. | |
// | |
// Xcode: 7.3 (7D175) | |
// Swift: Apple Swift version 2.2 (swiftlang-703.0.18.1 clang-703.0.29) | |
// Target: x86_64-apple-macosx10.9 | |
// | |
// These are the results on my machine when compiling with OTHER_SWIFT_FLAGS="-Xfrontend -debug-time-function-bodies": | |
// | |
// 601.7ms /Users/mexx/code/swift-bugs/SwiftSlowCompilePaintcode/SwiftSlowCompilePaintcode/Draw.swift:36:6 func drawSlow() | |
// 104.0ms /Users/mexx/code/swift-bugs/SwiftSlowCompilePaintcode/SwiftSlowCompilePaintcode/Draw.swift:30:6 func drawFast() | |
// | |
// This Problem still exists with the most recent swift snapshot 2.2.1-SNAPSHOT-2016-04-23-a | |
// | |
// 698.4ms /Users/mexx/code/swift-bugs/SwiftSlowCompilePaintcode/SwiftSlowCompilePaintcode/Draw.swift:36:6 func drawSlow() | |
// 62.6ms /Users/mexx/code/swift-bugs/SwiftSlowCompilePaintcode/SwiftSlowCompilePaintcode/Draw.swift:30:6 func drawFast() | |
// | |
import UIKit | |
// Code generated by PaintCode < 2.4.1 using `CGRectMake()` | |
func drawFast() { | |
let group: CGRect = .zero // This would normaly not be .zero, but for sake of a smaller example, .zero is sufficient | |
let rect = CGRectMake(group.minX + floor(group.width), group.minY + floor(group.height * 0.31667 - 0.49) + 0.99, floor(group.width * 0.82667 + 0.5) - floor(group.width * 0.71667 + 0.5), floor(group.height * 0.38667 - 0.49) - floor(group.height * 0.31667 - 0.49)) | |
} | |
// Code generated by PaintCode 2.4.1 using `CGRect()` | |
func drawSlow() { | |
let group: CGRect = .zero // This would normaly not be .zero, but for sake of a smaller example, .zero is sufficient | |
let rect = CGRect(x: group.minX + floor(group.width), y: group.minY + floor(group.height * 0.31667 - 0.49) + 0.99, width: floor(group.width * 0.82667 + 0.5) - floor(group.width * 0.71667 + 0.5), height: floor(group.height * 0.38667 - 0.49) - floor(group.height * 0.31667 - 0.49)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've already reported this to the swift team here https://bugs.swift.org/browse/SR-1346