I\'ve written two equivalent methods:
static bool F(T a, T b) where T : class
{
return a == b;
}
static bool F2(A a, A b)
{
return a == b;
Two things:
DateTime.Now. Use Stopwatch instead.If you switch the order of your tests (i.e. test the non-generic method first), does your result reverse? I would suspect so. When I plugged your code into LINQPad, and then copied it so that it ran both tests twice, the execution times for the second iteration were within a few hundred ticks of each other.
So, in answer to your question: yes, someone knows why. It's because your benchmark is inaccurate!