Remember new features, that make your code unreadable? A couple of days ago, CLR team released first preview of Parallel Computing for .NET. Isn't it really cool, that now you can use full power of your computer? I decided to test the extension and wrote simple routine, that throttles your CPU.
static int i=0;
static void MessMe()
{
for (;;)
{
i ++;
if (Console.KeyAvailable)
{
Console.ReadKey(true);
break;
}
}
}
Cool, now let's run it (with measurement) on my Dual Core 2 processor.
MessMe();
Nice, 54K simple math operations per second with half of each of my cores
It's already works (maybe because of my super OS?), but I still did not used it. Let's try to use the Parallel Computing extension.
Parallel.Do(MessMe);
What's going on with CPU?
Looks the same? Probably. Now the question is why the application performance degraded? Maybe it should know how much cycles I need?
And now with the Extension
Well, not really works. Let's try another method
Parallel.For(1, int.MaxValue, delegate(int k)
{
i = k;
if (Console.KeyAvailable)
{
Console.ReadKey(true);
}
});
Hmmm, it looks much better now, but still I do not understand that's going on here.
Yes, I know, this is stupid way to test framework and it's very early stage to judge, however, please someone can explain me what exactly wrong I'm doing?
Download Parallel Computing December CTP
1 comment:
Parrallel Computing only works faster with code that contains certain comands, instructions, parameters, subrouts, etc, out of the whole sets per language. Test it and see. When you added a variable it worked better to a point because variables are within parrallels ability. Works best with low level languages also.
Craig.
Post a Comment