This page is optimized for mobile devices, if you would prefer the desktop version just
click here
People sometimes take a week to make a decision, so we can’t fault a computer if it takes a few tens of nanoseconds. However, if an if-statement appears in some heavily traveled section of the code, you might get tired of the delay. There are two basic approaches to reducing the impact of branches:
- Streamline them.
- Move them out to the computational suburbs. Particularly, get them out of loops.
In [link] we show you some easy ways to reorganize conditionals so they execute more quickly.
Read also:
OpenStax, High performance computing. OpenStax CNX. Aug 25, 2010 Download for free at http://cnx.org/content/col11136/1.5
Google Play and the Google Play logo are trademarks of Google Inc.