Joseph Lord | How Swift is Swift?

Joseph Lord | How Swift is Swift?

Presented at www.swiftsummit.com

Swift Summit

March 21, 2015

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

13 slides
  1. SWIFT IS DESIGNED FOR SPEED Static Typing Value Types No

    pointer aliasing* Constants Copy on write @jl_hfl
  2. WHAT TO OPTIMISE Blocking I/O, Network efficiency, Library calls, Algorithmic

    complexity, Data structures. Build settings Profile and Measure Optimise General Code Metal/Accelerate/OpenGL/Parallelism @jl_hfl
  3. See video of build settings. And also the effect of

    using a class instead of a struct @jl_hfl
  4. MAKE TWO TARGETS ▸ Development - critical parts in Framework

    ▸ Release - all optimised, monolithic build. Test the Release builds Use C/C++ if really needed for core inner loop @jl_hfl
  5. HOW FAST IS SWIFT Within 20% of C/C++ version is

    usually possible. Geekbench - FFT and Mandelbrot Swift matches C++ but GEMM was 4 x faster in C++. David Owens - Gradient render 7 times faster in C (-Ofast). @jl_hfl
  6. SLOW THIS ONLY MATTERS IN THE REAL CODE HOTSPOTS ▸

    Global/class/static var (let is fine) ▸ Function calls that can't be inlined ▸ Access via protocol or to non-final class methods/properties ▸ @objc or NSObject @jl_hfl
  7. Links/Credits Primatelabs (Geekbench) - http://www.primatelabs.com/blog/ 2015/02/swift-performance-updated David Owens - http://owensd.io/2015/02/24/swift-1_2-beta-2.html

    My blog has several performance related posts: http://blog.human- friendly.com/ I'm @jl_hfl on Twitter. Thanks to Simon Gladman for the original Cellular Automata code. @jl_hfl

More Decks by Swift Summit

Other Decks in Programming