Parallelism Labs From Microsoft
February 1, 2011 Leave a comment
I did the PLINQ Lab this morning. The lab itself is fairly short and givers a great overview of both the power of Parallelism and the ease of use in C#. In addition, the last exercise shows how use Extension Methods on your IEnermable sources to further manipulate the data. My only gripe is that the VM screen real estate is very small:
And you can’t change the resolution on the VM desktop to see more of the code. The other gripe I have (only) is that the performance on the VM stinks – you literally wait 1-2 seconds after typing a character to see the intellisense to come up. This kind of context delay makes it harder to retain the information in the lab.
I then started the Introducing .NET4 Parallel Extensions lab. The screen delays were even worse so I took matters into my own hands. I took some screen shots of the lab created a local project based on the starting solution. One of the 1st tasks was to create a set of 20 random Employees. Instead of hard-coding values into the list, and limiting the list to only 20 employees, I decided to create a random employee generator as a WCF Service. That is the subject of this blog post
I had fun recreating the lab. I then went through each exercise. It did a good job explaining each of the aspects of Parallelism syntax. I have 1 note and 1 gripe. The note is that in the PLINQ, you can see how the TaskManager split the dataset in two process 1 took the 1st 50% and process 2 took the last 50%. Presumably, if I had a quad machine, it would be divided into four:
My 1 gripe has to do with the overuse of the ‘var’ keyword and the use of unreadable code in a public project. Take a swing though this syntax:
var q = employeeList.AsParallel()
.Where(x => x.Id % 2 == 0)
.OrderBy(x => x.Id)
.Select(x => PayrollServices.GetEmployeeInfo(x))
.ToList();
foreach (var e in q)
{
Console.WriteLine(e);
}
foreach(var e in q)??? Ugh! A little more thought about variable names (q should be employeeListQuery, x should be employee, e should also be employee). Oh well, the struggle continues…