Reputation: 9252
This example is from the PLINQ MSDN article:
http://msdn.microsoft.com/en-us/library/dd997399.aspx
var queryA = from num in numberList.AsParallel()
select ExpensiveFunction(num); //good for PLINQ
var queryB = from num in numberList.AsParallel()
where num % 2 > 0
select num; //not as good for PLINQ
Why isn't queryB considered 'delightfully parallel'? It seems like this would be ideal to split on multiple threads because each of the elements in the list is independent of the others.
Upvotes: 2
Views: 269
Reputation: 59020
The reason why the second example isn't a good candidate for paralellization is simply because the overhead incurred in splitting the work up over multiple threads is generally high, so the work done in parallel would have to outweigh that overhead. An inexpensive operation is not a good candidate.
Upvotes: 4