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

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!

主站蜘蛛池模板: 湟中县| 永登县| 沅江市| 永春县| 宁明县| 阿图什市| 松阳县| 许昌县| 北流市| 遵义市| 德昌县| 布拖县| 临朐县| 烟台市| 固镇县| 贡山| 子长县| 赤水市| 延吉市| 梅河口市| 黔南| 武胜县| 揭阳市| 博爱县| 新巴尔虎左旗| 郎溪县| 江源县| 衡山县| 肥城市| 北京市| 许昌市| 丹寨县| 清镇市| 哈巴河县| 集安市| 茶陵县| 印江| 朝阳县| 定陶县| 甘洛县| 达日县|