3 ms·
> So to repeat, the code only removes adjacent duplicate values. yup. author wants to see how far can things be taken, and with simd in play, you can do approx
by signa11 10y ago
> So to repeat, the code only removes adjacent duplicate values.
yup. author wants to see how far can things be taken, and with simd in play, you can do approx. 1 cycle / array-op, which is an order of magnitude better than c++ std::unique.
- gus_massa 10y agoThe speedup is interesting. I specially like to read other example where killing an `if` increase the performance easily. `if`s are bad! The SIMD operations get much more speed, but here we can start a discussion about portability and maintainability. It's a trick to use only in a very special case. Anyway, removing the consecutive duplicates of a vector is an O(N) operation, but sorting the vector is an O(N log(N)) operation. So in any real example the sorting part will be slower than the removing part. To make the whole operation quicker it's better to improve the sorting part. It's a nice article, but hiding the slowest part of the operation under the rug is a bit misleading.