官术网_书友最值得收藏!

  • Swift High Performance
  • Kostiantyn Koval
  • 187字
  • 2021-08-05 16:36:23

Swift speed

I can guess you opened this book because you are interested in speed and are probably wondering, "How fast can Swift be?" Before you even start learning Swift and discovering all the good things about it, let's answer it right here and right now.

Let's take an array of 100,000 random numbers; sort it in Swift, Objective-C, and C using the standard sort function from stdlib (sort in Swift, qsort in C, and compare in Objective-C); and measure how much time each would take.

Sorting an array with 100,000 integer elements gives us this:

And the winner is, Swift! Swift is 14.5 times faster than Objective-C and 2.3 times faster than C.

In other examples and experiments, C is usually faster than Swift and Swift is way faster than Objective-C. These measurements were done with Xcode 7.0 beta 6 and Swift 2.0. It's important to highlight that the improvements in Swift 2.0 were mainly focused on making it cleaner, more powerful, safer, and more stable, and preparing it for open sourcing. Swift's performance hasn't reached its full potential yet, and the future is so exciting!

主站蜘蛛池模板: 墨竹工卡县| 巴东县| 西华县| 达孜县| 建湖县| 永登县| 霍邱县| 共和县| 丹巴县| 静海县| 泗水县| 遂平县| 定兴县| 霍林郭勒市| 修文县| 金昌市| 宁晋县| 凌海市| 浦北县| 深水埗区| 苍南县| 天门市| 云南省| 都江堰市| 博乐市| 莱州市| 东丽区| 乌鲁木齐县| 临汾市| 怀安县| 康乐县| 桂林市| 大田县| 云和县| 报价| 湄潭县| 启东市| 鞍山市| 贵德县| 抚顺市| 新蔡县|