title: Should LINQ be avoided because it's slow?
body: <p>I've had been told that since .net linq is so slow we shouldn't use it and was wondering anyone else has come up with the same conclusion, and example is:</p>
  
  <p>Took 1443ms to do 1000000000 compares non-LINQ.<br>
  Took 4944ms to do 1000000000 compares with LINQ.<br>
  (243% slower)</p>
  
  <p>the non-LINQ code:</p>
  
  <pre><code>for (int i = 0; i &lt; 10000; i++)
  {
      foreach (MyLinqTestClass1 item in lst1) //100000 items in the list
      {
          if (item.Name == "9999")
          {
              isInGroup = true;
              break;
          }
      }
  }
  </code></pre>
  
  <p>Took 1443ms to do 1000000000 compares non-LINQ.</p>
  
  <p>LINQ code:      </p>
  
  <pre><code>for (int i = 0; i &lt; 10000; i++)  
      isInGroup = lst1.Cast&lt;MyLinqTestClass1&gt;().Any(item =&gt; item.Name == "9999");  
  </code></pre>
  
  <p>Took 4944ms to do 1000000000 compares with LINQ.</p>
  
  <p>I guess its possible to optimize the LINQ code but the thought was that its easily to get really slow LINQ code and given that it shouldn't be used. Given that LINQ is slow then it would also follow that PLINQ is slow and NHibernate LINQ would be slow so any kind on LINQ statement should not be used. </p>
  
  <p>Has anyone else found that LINQ is so slow that they wished they had never used it, or am I making a too general conclusion based on benchmarks like this?</p>