The last two weeks Ive found myself immersed in looking at the new Pfx CTP release. I must say it has come on loads since the last drop in December. Some of the issues I spoke about in a previous blog post have now been fixed, things like better algorithms for Parallel.For. Perhaps some of the best addition is the set of concurrent data structures ( cds ).
The main reason for digging into Pfx over the last two weeks was to write an article for the August edition of Developmentor's "development's" monthly news letter, this article attempts to cover the highlights of the recent CTP, so after completing that part of it I had to find some fun use of Pfx, so I ported a developmentor favorite "Boids". Anyone attending a Developmentor Esessntial .NET or Guerilla .NET will have probably encountered this app, but for those not in the know it is a simulation of flocking behaviour.
I took the initial code written by Jason Whittington and started tuning it for performance initially just using one core. The main task was to reduce the number of loops, so instead of having two loops one after each other that iterate over the same set of data I simply combined them, and the second optimisation was to replace foreach with a regular for loop. After that I replaced the main outer for loop with Parallel.For , and viola a reasonable speed up...
I've run the code on my dual core and on an eight way and in both cases observed a reasonable speed up...Not bad considering not a massive amount of effort.
You can download the code from here
No comments:
Post a Comment