A severe lack of sleep and the "too many irons in the fire" syndrome has left me a tad frazzled, so instead of a well-written (I see you laughing!) post, you get a collection of random thoughts and observations:
Too much lambda?
I wonder if I’m relying too heavily on lambda expressions. What do you think, is this going too far (extracted from one of my unit tests):
See line 10 for what I mean. The formula for counting the number of possible undirected graphs with a given number of vertices is quite simple, and it just didn’t "feel" like it needed to be a method; I just wanted to alias the expression so that I could easily reuse it. Is this a bad thing? Should I have created a private helper method instead (complete with comments and all that jazz)?
Parallel Extensions == Awesome
One of my assignments for grad school was to create a graph coloring application (I won’t get in to details, and no, I won’t be posting the code for that), but if you’ve ever messed with graph coloring, you know that the time taken to find a valid coloring increases greatly as the complexity of your graph increases. Well, I wrote my solution in C#, and I wasn’t satisfied with the runtime, so I used the Parallel Extensions June CTP release to parallelize it. The improvements were impressive. Sequentially, calculating the average number of colors needed to "colorize" all graphs of size <= 8 took about 1.5 hours (in DEBUG) on a dual-dual core Opteron workstation, with only one core saturated (a huge waste). I applied Parallel.ForEach in the problem, and the run-time dropped to 28 minutes. That’s impressive. 🙂
Parallel Extensions == Ugly
Despite the huge performance gains that are available by leveraging multiple cores, I still think the API has a long way to go. Here’s the sequential work-horse of my algorithm:
And here’s the parallel version:
As you can see, it looks like the unreadable code fairy sprinkled pixie dust all over the sequential version, then kicked it in the knees and took its wallet. There needs to be a better, more readable way to do aggregations like this.
Yeah, for this week anyway. Next week I hope to write more about DeepCrawler.NET (there’s a chance that my current employer may even adopt the code, which means I could actually get paid to work on it!), but if anyone would rather see/hear about something else, let me know.