title: Key indicators that a Java 8 stream will run slower than a for loop?
body: <p>Java 8 streams allow code that is a lot more readable than old-fashioned <code>for</code> loops, in most cases. However, based on my own experience and what I've read, using a stream instead of a for loop can involve a performance hit (or occasionally an improvement) which is sometimes difficult to predict.</p>
  
  <p>In a large project it doesn't seem feasible to write a benchmark test for every loop, so <strong>when deciding whether to replace a <code>for</code> loop with a stream, what are the key factors</strong> (e.g. expected size of the collection, expected percentage of values removed by filtering, complexity of iterative operations, the type of reduction or aggregation, etc.) <strong>which give a likely indication of the performance change that will result?</strong>  </p>
  
  <p><em>Note: this is a narrowing of <a href="https://stackoverflow.com/questions/34629489/rules-of-thumb-for-java-8-streams?noredirect=1#comment57005274_34629489">my earlier question</a>, which was closed for being too broad (and for which the aspects of parallel streams were pretty well covered <a href="https://stackoverflow.com/questions/20375176/should-i-always-use-a-parallel-stream-when-possible/23370799#23370799">in another SO question</a>), so let's just limit this to sequential streams.</em>  </p>