views:

45

answers:

0

My application compiled in .NET 4 seems to be performing really slow compared to .NET 3.5. When I did the performance analysis, I found out that the System.Math libraries in VS2010/.NET 4 have slowed down considerably.

Any explanation to this? Has anyone else come across this or am I the only one seeing this?

UPDATE:

My sample code looks like this:

for (int i = 0; i < 10; i++)
    {
        for (int j = 0; j < 1000000; j++)
        {
            Min((double) ((j + 1) / 2), (double) ((j + 2) / 2));
        }
        for (int k = 0; k < 1000000; k++)
        {
            Min((double) ((k + 2) / 2), (double) ((k + 3) / 2));
        }
        for (int m = 0; m < 1000000; m++)
        {
            Min((double) ((m + 3) / 2), (double) ((m + 4) / 2));
        }
        for (int n = 0; n < 1000000; n++)
        {
            Min((double) ((n + 4) / 2), (double) ((n + 5) / 2));
        }
    }

The above code takes 0.55 seconds in framework 3.5. The same takes 0.8 seconds in .NET 4. Similar performance issues I have seen in other functions also like Truncate, Floor and Max amongst others.

Thanks, Niranjan