Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Limited import clarification and its effect/tryswift2019

Limited import clarification and its effect/tryswift2019

Import is able to explicitly specify submodules or specific elements.In this session, I will review the specifications of these imports and consider the impact on binary size and performance.

3e66b3ccfa617b78c59d9dec865aa29f?s=128

noppefoxwolf

March 21, 2019
Tweet

Transcript

  1. Limited import clarification and its effect try! Swift Tokyo 2019

    Tomoya Hirano @DeNA
  2. Import

  3. Import Declaration 1. attributes import module 2. attributes import module.submodule

    3. attributes import importKind module.symbolName
  4. Import Declaration 1. attributes import module 2. attributes import module.submodule

    3. attributes import importKind module.symbolName
  5. 1. Attributes • Specify how to import symbols • Optional

    • @testable / @_exported
  6. @testable • For testing and development. • Import internal methods

    as public.
  7. @_exported • Import symbols as own code • Undocumented attributes

  8. 2. Submodule import 1. attributes import module 2. attributes import

    module.submodule 3. attributes import importKind module.symbolName
  9. Example: SceneKit initializer

  10. Example: SceneKit initializer

  11. 3. Kind import 1. attributes import module 2. attributes import

    module.submodule 3. attributes import importKind module.symbolName
  12. struct class enum protocol typealias func let var 3. Kind

    import
  13. 3. Kind import • Individual import is only top-level •

    Cannot import overloaded functions separately
  14. Example: Conflict method name

  15. None
  16. 1. Attributes 2. Submodule import 3. Kind import Import Options

  17. Can the build time be shortened?

  18. 4. Measuring the build times • made 100,000 methods •

    import Core vs import func Core.function0 • Tried 10 times
  19. Basic Import Kind Import Average 277.645s 285.105s(+7.64s) Max 309.46s 312.99s(+3.53s)

    Min 273.48s 265.25s(-8.23s) Build time
  20. Basic Import Kind Import Filesize 7336KB 7336KB Md5 0b10a59ce0a75decbb 2f120520c4fbc1

    0b10a59ce0a75decbb 2f120520c4fbc1 Binary size
  21. Build time Binary Size Namespace Simple Import Same Same Optional

    Kind specify Same Same Necessary Pros & Cons