3 ms·
Thanks. I do not see that when I use what I would think to be the straightforward way to count (using integers), though: var count = Int() for var i in arr
by Someone 11y ago
Thanks. I do not see that when I use what I would think to be the straightforward way to count (using integers), though:
var count = Int()
for var i in array
{
i += negBoundary
let delta = (i > 0.0) ? 1 : 0
count += delta
}
(timed using mach_absolute_time(), on my system, that code also seems about twice as fast as the SIMD code)
I did not check whether that trigraph gets compiled to a branch (I tried, but I had trouble reading the disassembly that otool gave me; I’m not used to x86, and I found the code surprisingly long)