Did you know that the performance of an if-statement depends on whether its condition has a predictable pattern? If the condition is always true or always false, the branch prediction logic in the processor will pick up the pattern. On the other hand, if the pattern is unpredictable, the if-statement will be much more expensive. In this article, I’ll explain why today’s processors behave this way.
Monday, January 31, 2011
Fast and slow if-statements: branch prediction in modern processors
http://igoro.com/archive/fast-and-slow-if-statements-branch-prediction-in-modern-processors/
Labels:
Links
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment