After I upgraded my projects to .NET 4.0 (With VS2010) I realized than they run slower than they were in .NET 2.0 (VS2008). So i decided to benchmark a simple console application in both VS2008 & VS2010 with various Target Frameworks:
using System;
using System.Diagnostics;
using System.Reflection;
namespace RuntimePerfTest
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(Assembly.GetCallingAssembly().ImageRuntimeVersion);
Stopwatch sw = new Stopwatch();
while (true)
{
sw.Reset();
sw.Start();
for (int i = 0; i < 1000000000; i++)
{
}
TimeSpan elapsed = sw.Elapsed;
Console.WriteLine(elapsed);
}
}
}
}
Here is the results:
- VS2008
- Target Framework 2.0: ~0.25 seconds
- Target Framework 3.0: ~0.25 seconds
- Target Framework 3.5: ~0.25 seconds
- VS2010
- Target Framework 2.0: ~3.8 seconds
- Target Framework 3.0: ~3.8 seconds
- Target Framework 3.5: ~1.51 seconds
- Target Framework 3.5 Client Profile: ~3.8 seconds
- Target Framework 4.0: ~1.01 seconds
- Target Framework 4.0 Client Profile: ~1.01 seconds
My initial conclusion is obviously that programs compiled with VS2008 working faster than programs compiled with VS2010.
Can anyone explain those performance changes between VS2008 and VS2010? and between different Target Frameworks inside VS2010 itself?