Lately i have been doing some work with sending emails and I have chosen to use some of .NET4.0’s Parallel processing and the FluentEmail library.
I then got thinking about the Performance differences between using Parallel against Asynchronous so I decided to run some tests. Based of the C# Micro Performance Testing Class blog post I have written a simple app for testing this.
Firstly I created my base class for the performance tests, this will later be inherited by by different testers.
Pretty basic, methods to start and finish that set the stopwatch and the finished bool…
Now that we have the stone to build off we can create the classes for the tests we went to perform, in this case 1 for Async and 1 for Parallel (below) these 2 classes then just override the Run method and call Finish when its done. However the async class differs slightly as it has to wait for the async callback.
Now for some results, now I know the performance will differ depending on PC hardware so I'm testing this on 2 different PCs the first has a Core 2 Duo E6400 @ 2.13GHz and the 2nd has a Core 2 Quad Q6600 @ 2.4GHz.
Table represents my results of the tests (in milliseconds)
|Emails Sent||Parallel (Dual Core)||Parallel (Quad Core)||Async
Just a note, these tests were run from the 2 PCs on the same network with the same internet connection connecting to gmails smtp server. Of course there are other factors that would affect performance of these 2 methods but this is just to get an idea of the differences.
Read into that as much as you want but the main thing i got from it is parallel processing is better when you have more cores (which isn't really anything new at all). Good to see the difference in results though.