Dr. Dobb's Journal - February 2009 - (Page 35) times sequentially and three times in parallel—referring to the for loop and Cypher.ScrambleSequentially and Cypher.ScrambleParallel methods. Performance improves significantly after ScrambleParallel is called the first time; this is probably due to how long it takes to queue worker threads the first time. The text is encrypted and a Stopwatch is used to display the elapsed time. The EncryptLine and DecryptLine methods work by using the simple substitution cypher generated in CreateNewCypher. CreateNewCypher uses all of the uppercase letters of the alphabet and assigns one of 26 possible substitute values until all letters are exhausted. Thus, A might be randomly substituted for F, B for Z, and so on. The easiest way to decrypt is to reverse the process using the same cypher values. (Or use trial-anderror, manually, which any first-year cryptographer could do. You could probably use something like this to perplex casual snoops, but I wouldn’t break any laws and encode details in an e-mail using cypher substitution—if you know what I mean.) Of course, not all problems are amenable for parallel execution. For instance, the cypher example didn’t work so well at the character level, probably because the limited amount of work—substituting one character at a time—costs less than partitioning the data and spinning threads. You can enhance the results of parallel performance by following a few basic recommendations: • Target computationally expensive algorithms, for example, where you are processing thousands or millions of items. • Consider using the server garbage collection for parallel applications. Refer to the MSDN help documentation for the gcServer.config element. • Parallize outer but not inner loops unless the outer loop processes a few iterations and the inner loop processes many iterations—then process the inner loop but not the outer. • Avoid enabling ordering and using order by unless absolutely necessary. • Prefer independent loop iterations and System.Threading.Tasks.Task bodies instead of using synchronization. • Pay attention to the number of explicit Task bodies because some overhead is incurred. • And of course, this code is still CTP, so hopefully feedback and a few more developer cycles will improve performance. It is worth noting that PLINQ is part of Parallel FX, so some of these tips apply to parallelism in general. Conclusion There are several samples with the Parallel FX Library (www.microsoft.com/downloads/ details.aspx?FamilyId=348F73FD-593D4B3C-B055-694C50D2B0F3&displaylang =en/), including a ray tracer and a C++ example that renders Mandelbrot Fractals. When I ran the ray tracer algorithm, the image rendered in 47 seconds sequentially and in 32 seconds in parallel. DDJ Download a proven, cross-platform database alternative • Unmatched performance in enterprise systems, desktop deployments, and embedded devices for over 25 years. • Simplified framework for rapid development of data-driven applications including graphical tools to speed your development and monitor critical metrics of the database engine. • Free development and free deployment in non-commercial environments. • Flexibility to use ISAM and SQL API’s within the same application. • Sophisticated feature set including 64-bit support, memory files, ADO.NET, LINQ, C#, VCL, and dbExpress. • Cross Platform support including Windows, UNIX, Linux, Mac OS X, and more. • OEM Database Engine simplifies your deployment with a single executable and flexible licensing options. Prove it to yourself in six minutes. Download today! www.faircom.com February 2009 l www.ddj.com l Dr. Dobb’s Journal 35 http://www.microsoft.com/downloads/details.aspx?FamilyId=348F73FD-593D-4B3C-B055-694C50D2B0F3&displaylang=en/ http://www.microsoft.com/downloads/details.aspx?FamilyId=348F73FD-593D-4B3C-B055-694C50D2B0F3&displaylang=en/ http://www.microsoft.com/downloads/details.aspx?FamilyId=348F73FD-593D-4B3C-B055-694C50D2B0F3&displaylang=en/ http://www.faircom.com http://www.faircom.com http://www.ddj.com
Table of Contents Feed for the Digital Edition of Dr. Dobb's Journal - February 2009 Dr. Dobb's Journal - February 2009 Contents Friday Night Fish Fry Alia Vox Developer Diaries Conversations Computing in the Clouds Software Development in the Cloud Videos and Oracle Forms 10g Parallel LINQ Decoupling C Header Files Effective Concurrency Disciplined Agility Swaine’s Flames Dr. Dobb's Journal - February 2009 Dr. Dobb's Journal - February 2009 - (Page BB1) Dr. Dobb's Journal - February 2009 - (Page BB2) Dr. Dobb's Journal - February 2009 - Dr. Dobb's Journal - February 2009 (Page Cover1) Dr. Dobb's Journal - February 2009 - Dr. Dobb's Journal - February 2009 (Page Cover2) Dr. Dobb's Journal - February 2009 - Dr. Dobb's Journal - February 2009 (Page 1) Dr. Dobb's Journal - February 2009 - Dr. Dobb's Journal - February 2009 (Page 2) Dr. Dobb's Journal - February 2009 - Dr. Dobb's Journal - February 2009 (Page 3) Dr. Dobb's Journal - February 2009 - Contents (Page 4) Dr. Dobb's Journal - February 2009 - Contents (Page 5) Dr. Dobb's Journal - February 2009 - Friday Night Fish Fry (Page 6) Dr. Dobb's Journal - February 2009 - Friday Night Fish Fry (Page 7) Dr. Dobb's Journal - February 2009 - Friday Night Fish Fry (Page 8) Dr. Dobb's Journal - February 2009 - Friday Night Fish Fry (Page 9) Dr. Dobb's Journal - February 2009 - Alia Vox (Page 10) Dr. Dobb's Journal - February 2009 - Alia Vox (Page 11) Dr. Dobb's Journal - February 2009 - Developer Diaries (Page 12) Dr. Dobb's Journal - February 2009 - Developer Diaries (Page 13) Dr. Dobb's Journal - February 2009 - Conversations (Page 14) Dr. Dobb's Journal - February 2009 - Conversations (Page 15) Dr. Dobb's Journal - February 2009 - Computing in the Clouds (Page 16) Dr. Dobb's Journal - February 2009 - Computing in the Clouds (Page 17) Dr. Dobb's Journal - February 2009 - Computing in the Clouds (Page 18) Dr. Dobb's Journal - February 2009 - Computing in the Clouds (Page 19) Dr. Dobb's Journal - February 2009 - Computing in the Clouds (Page 20) Dr. Dobb's Journal - February 2009 - Computing in the Clouds (Page 21) Dr. Dobb's Journal - February 2009 - Software Development in the Cloud (Page 22) Dr. Dobb's Journal - February 2009 - Software Development in the Cloud (Page 23) Dr. Dobb's Journal - February 2009 - Software Development in the Cloud (Page 24) Dr. Dobb's Journal - February 2009 - Software Development in the Cloud (Page 25) Dr. Dobb's Journal - February 2009 - Software Development in the Cloud (Page 26) Dr. Dobb's Journal - February 2009 - Software Development in the Cloud (Page 27) Dr. Dobb's Journal - February 2009 - Videos and Oracle Forms 10g (Page 28) Dr. Dobb's Journal - February 2009 - Videos and Oracle Forms 10g (Page 29) Dr. Dobb's Journal - February 2009 - Videos and Oracle Forms 10g (Page 30) Dr. Dobb's Journal - February 2009 - Videos and Oracle Forms 10g (Page 31) Dr. Dobb's Journal - February 2009 - Parallel LINQ (Page 32) Dr. Dobb's Journal - February 2009 - Parallel LINQ (Page 33) Dr. Dobb's Journal - February 2009 - Parallel LINQ (Page 34) Dr. Dobb's Journal - February 2009 - Parallel LINQ (Page 35) Dr. Dobb's Journal - February 2009 - Decoupling C Header Files (Page 36) Dr. Dobb's Journal - February 2009 - Decoupling C Header Files (Page 37) Dr. Dobb's Journal - February 2009 - Decoupling C Header Files (Page 38) Dr. Dobb's Journal - February 2009 - Decoupling C Header Files (Page 39) Dr. Dobb's Journal - February 2009 - Effective Concurrency (Page 40) Dr. Dobb's Journal - February 2009 - Effective Concurrency (Page 41) Dr. Dobb's Journal - February 2009 - Effective Concurrency (Page 42) Dr. Dobb's Journal - February 2009 - Effective Concurrency (Page 43) Dr. Dobb's Journal - February 2009 - Disciplined Agility (Page 44) Dr. Dobb's Journal - February 2009 - Disciplined Agility (Page 45) Dr. Dobb's Journal - February 2009 - Disciplined Agility (Page 46) Dr. Dobb's Journal - February 2009 - Disciplined Agility (Page 47) Dr. Dobb's Journal - February 2009 - Swaine’s Flames (Page 48) Dr. Dobb's Journal - February 2009 - Swaine’s Flames (Page Cover3) Dr. Dobb's Journal - February 2009 - Swaine’s Flames (Page Cover4)
For optimal viewing of this digital publication, please enable JavaScript and then refresh the page. If you would like to try to load the digital publication without using Flash Player detection, please click here.