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

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!

主站蜘蛛池模板: 平南县| 扶余县| 丽江市| 博野县| 板桥市| 华阴市| 南部县| 南汇区| 天镇县| 轮台县| 资阳市| 邢台市| 盈江县| 公主岭市| 泽库县| 姜堰市| 康乐县| 龙陵县| 山东省| 民丰县| 沈阳市| 烟台市| 平果县| 谢通门县| 华安县| 阳江市| 东海县| 寻乌县| 河南省| 沛县| 禹城市| 进贤县| 罗田县| 休宁县| 闽侯县| 昌平区| 怀安县| 思南县| 康马县| 大悟县| 镶黄旗|