7 ms·
Don't trust your compiler. Your code is only fast if you're lucky. https://tiki.li/blog/lucky_code.html https://tiki.li/blog/lucky_code.html
by chrka 2mo ago
Don't trust your compiler. Your code is only fast if you're lucky.
https://tiki.li/blog/lucky_code.html https://tiki.li/blog/lucky_code.html
- charleslmunger 2mo agoI agree you can't trust your compiler, but you can control its behavior more reliably with __builtin_expect_with_probability https://github.com/protocolbuffers/protobuf/commit/9f29f02a36ae0d2689ca7feebd2d07018436bcde https://github.com/protocolbuffers/protobuf/commit/9f29f02a3...
- foxhill 2mo agothat's a nice example. on my M4, i measured 3.4s vs. 0.42s. honestly surprised there's ~10x improvement to be found. as you've pointed out, you've literally micro-optimised this - isn't this what you'd expect? :)
- ks6g10 2mo agoBut what is the resulting assembly? I would assume completely different!