Slower .NET 4 platform performance

I am very surprised by the results of my .net frameworks performance tests. Take a look at the code:

static void Main(string[] args)
{
    var s1 = Stopwatch.StartNew();
    for (long len = 8000000; len <= 16000000; len += 2000000)
    {
        for (int i = 0; i < 30; i++)
        {

            long sum = 0;
            for (int x = 1; x <= len; x++)
            {
                sum += x;
            }

        }
    }
    s1.Stop();
    Console.WriteLine(s1.Elapsed.TotalMilliseconds);
}

When I target .net 2.0, 3.0, 3.5 and x64 platforms, the result is 520 ms . When I am targeting .net 4.0, 4.5, 4.6 and x64 platforms, the result is 1230 ms . When x86 platform targeting is around 1560 ms for all frameworks. My computer is x64 based. The question is, why is there such a big difference between .NET networks under 4th and higher? All examples were built using vs2015 in release mode with default settings.

+4
source share

Source: https://habr.com/ru/post/1613312/


All Articles