I have made several tests for testing access times of properties and fields.
I have this method for Measuring:
static void Measurer(Action act)
{
Stopwatch stop = Stopwatch.StartNew();
for (int i = 0; i < 10000000; i++)
{
act.Invoke();
}
stop.Stop();
Console.WriteLine(stop.Elapsed);
}
I have some simple class with some properties and fields, so I have two tests for this:
Measurer(() =>
{
built1.LevelID = built.LevelID;
built1.Enabled = built.Enabled;
built1.Profile = built.Profile;
built1.Modes = built.Modes;
});
Measurer(() =>
{
built1.levelID = built.levelID;
built1.enabled = built.enabled;
built1.profile = built.profile;
built1.modes = built.modes;
});
I am also testing different reflection methods, but here these tests are just to show the difference. Project is for 4.5 framework. So I build the project in Release x64 when I run on my laptop with i5 CPU on Windows 7 I have these results:
I have access to the server machine where I decided to test, it's Xeon E560 2.4 Ghz with 2 processors on Windows Server 2008 R2 and I have this result:
So why I have this big difference on better machine? What causes this difference? Any thoughts? I can think of different things, but this will be just suggestions, maybe somebody knows why?