[swift-dev] A question about compile times for global constants
Rahul Ranjan
rahul.rrixe at gmail.com
Fri Nov 17 01:11:19 CST 2017
This is an interesting analysis. I am interested in knowing answer to the
OP’s second question.
Also, what were the some cases where the behaviour is different?
On Fri, 17 Nov 2017 at 8:52 AM, Oscar Bonilla via swift-dev <
swift-dev at swift.org> wrote:
> Hi swift-dev,
>
> I was trying to determine the most efficient way to store constants in
> swift without impacting compilation time. I started off by creating a
> python script (attached) that just creates a swift file with a single type
> with 1, 2, 4, 8, …, 1024 fields. The type could be enum, struct, or class.
> And the field declaration can be ‘case’ (for enum), ‘let’, or ‘static let’.
>
> Now to the interesting part, I plotted the size of the resulting .o file
> and this is what I got:
>
>
>
> Looking at this it looks like enum/case is the way to go, however I also
> plotted the time it took to compile the swift file:
>
>
>
> One thing that surprised me is that for some common cases (enum/case,
> class/let, and struct/let) the compilation time seems at least quadratic.
>
> Is this something that is well known or have I stumbled on a corner-case?
>
> I’m attaching both the script I used for generating the tests and the R
> script used for plotting. (Please excuse the small images, I tried sending
> the email with large images and it bounced).
>
> What is the most space/compile time efficient way to handle constants?
>
> Cheers,
>
> -Oscar
>
>
> _______________________________________________
> swift-dev mailing list
> swift-dev at swift.org
> https://lists.swift.org/mailman/listinfo/swift-dev
>
--
Rahul
Sent from iPhone
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20171117/2d44a184/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PastedGraphic-3.png
Type: image/png
Size: 50579 bytes
Desc: not available
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20171117/2d44a184/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PastedGraphic-2.png
Type: image/png
Size: 46155 bytes
Desc: not available
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20171117/2d44a184/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PastedGraphic-3.png
Type: image/png
Size: 50579 bytes
Desc: not available
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20171117/2d44a184/attachment-0002.png>
More information about the swift-dev
mailing list