DCSIMG
Software is sucks? Probably it really is! - Just code - Tamir Khason
Monday, December 03, 2007 7:57 PM Tamir Khason

Software is sucks? Probably it really is!

[This blog was migrated. You will not be able to comment here.
The new URL of this post is http://khason.net/blog/software-is-sucks-probably-it-really-is/]


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();

image

Nice, 54K simple math operations per second with half of each of my cores

image

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);

image

What's going on with CPU?

image

Looks the same? Probably. Now the question is why the application performance degraded? Maybe it should know how much cycles I need?

image

And now with the Extension

image

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);
                }
            });

 image

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

תגים:, , , , , ,

Comments

No Comments