- A=10309 B=689
- A=83 B=84
- A=79 B=84
- A=72 B=91
- A=76 B=83
- A=78 B=85
- A=89 B=83
- A=74 B=95
- A=75 B=87
- A=75 B=89
My functions are listed following:
public static void A()
{
List a = Enumerable.Range(1, 1000).ToList();
var r = 0;
var count = a.Count;
for (int i = 0; i < count; i++)
r += a[i];
}
public static void B()
{
IList a = Enumerable.Range(1, 1000).ToList();
var r = 0;
var count = a.Count;
for (int i = 0; i < a.Count; i++)
r -= a[i];
}
It seems that List object is kept and reused in A and B. I was expecting the interface one is slower, but the result show the opposite.
No comments:
Post a Comment