Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>tl;dr</strong> IMHO, Avoiding exceptions for performance reasons hits both categories of premature and micro- optimizations. Don't do it.</p> <p>Ah, the religious war of exceptions.</p> <p>The various types of answers to this are usually:</p> <ul> <li>the usual mantra (a good one, IMHO): "use exceptions for exceptional situations" (IOW, not part of "normal" code paths). <ul> <li>If your normal user paths involved intentionally using exceptions as a control-flow mechanism, that's a smell.</li> </ul></li> <li>tons of detail, without really answering the original question <ul> <li>if you really want detail: </li> <li><a href="http://blogs.msdn.com/cbrumme/archive/2003/10/01/51524.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/cbrumme/archive/2003/10/01/51524.aspx</a></li> <li><a href="http://blogs.msdn.com/ricom/archive/2006/09/14/754661.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/ricom/archive/2006/09/14/754661.aspx</a></li> <li>etc.</li> </ul></li> <li>someone pointing at microbenchmarks showing that something like i/j with j == 0 is 10x slower catching div-by-zero than checking j == 0</li> <li>pragmatic answer of how to approach performance for apps in general <ul> <li>usually along the lines of:</li> <li>make perf goals for your scenarios (ideally working with customers)</li> <li>build it so it's maintainable, readable, and robust</li> <li>run it and check perf of goal scenarios</li> <li>if a set of scenarios aren't making goal, USE A PROFILER to tell you where your time is being spent and go from there.</li> <li>IOW, any perf changes, especially micro-optimizations like this, made without profiling data driving that decision, is typically a huge waste of time.</li> </ul></li> </ul> <p>Keep in mind that your perf wins will typically come from algorithmic changes (adding an index to a table to avoid table scans, moving something with large n from O(n^3) to O(n ln n), etc.).</p> <p>More fun links: </p> <ul> <li><a href="http://en.wikipedia.org/wiki/Program_optimization" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Program_optimization</a></li> <li><a href="http://www.flounder.com/optimization.htm" rel="nofollow noreferrer">http://www.flounder.com/optimization.htm</a></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload