Re:10 thousand times faster Swift
by toth on Tuesday May 17, 2016 @10:16AM
(#11713813)
The function call is not being optimized out, it's being hoisted outside the loop. I.e., it is as if the code was written as:
The counter will still be correct, but you are not measuring what you think you are measuring.
[ Parent
| on HN ]
This makes sense!
Changed the iteration to:
for i in 0..<iterations {
let result = flatuseStruct(outputData, start:i)
assert(result == 8644311666 + Int(i))
total2 = total2 + UInt64(result)
}
now result is around 43msThanks for pointing it out. Have to check if there are so other things involved, but that might be it.