6 ms·
However, if you look at the second, you won't see any left shifts, which is also interesting
by DannyBee 8y ago
However, if you look at the second, you won't see any left shifts, which is also interesting
- ascar 8y agoI find it weird that he doesn't mention this difference as part of the performance difference. A left shift should be considerably faster than a mul operation?
- foldr 8y agoI don't think this is generally true on modern processors.
- acdha 8y agoI believe this is far less true than it used to be, but it’s a good example of why these decisions really need to be data driven as compilers and processors change faster than most people can afford to optimize code. I don’t know that this would be the case for something that simple but I’ve seen a fair amount of heavily-tuned C/ASM code which was replaced with the now-faster “reference” code when someone noticed that the old assumptions weren’t true.