I'm trying to understand when the usage of parallel
will increase the performance.
I tested it with a simple code that ran over 100,000 items in List<Person>
and changed the name of each one to string.Empty
.
The parallel version took twice the time then the regular version. (Yes I tested with more the one core...)
I saw this answer saying a slice of data that not always the parallel is good for performance.
Also this caution repeated in each page of the parallel examples in the MSDN tutorial:
These examples are primarily intended to demonstrate usage, and may or may not run faster than the equivalent sequential LINQ to Objects queries
I need some rules and tips when parallel will increase the performance of my code and when will not.
The obvious answer is "Test your code, if the parallel loop is faster use it", is absolutely right, but I guess no one run performance analysis on each loop he writes.