W
Willy Denoyette [MVP]
Jon Skeet said:I was doing the rounding myself - I remember that your version was
actually about 8900ms, but I can't remember the other ones.
Here are the results for 2 billion, in ms - 2.5 billion takes us over
int.MaxValue, and changing the loop variables to be longs changes the
results significantly.
Hilton: 18675
Jon: 25219
Math.Min: 26844
A larger proportional difference than before, but still less than your
results.
Yes, that would be interesting. I'm still surprised that Math.Min
doesn't end up being the same speed as your code though - I'd expect
inlining to take care of it all.
Currently on v2, defining this:
return Math.Min( Math.Min(a[0], a[1]), Math.Min(a[2], a[3]));
in general stops the JIT from optimizing the arguments, make it look like:
int x = Math.Min(a[0], a[1]);
int y = Math.Min(a[2], a[3]);
return Math.Min(x, y);
and watch the results.
Also, note that running these tests in sequence produce different results
from running them separately (one per process).
Willy.