A few minutes of work and you can benchmark this yourself reasonably enough to see the difference.
1.) Create a general purpose timing routine.
public void RunTest(Action action, String name, Int32 iterations)
{
var sw = new System.Diagnostics.Stopwatch();
System.GC.Collect();
System.GC.WaitForPendingFinalizers();
sw.Start();
for(var i = 0; i<iterations; i++)
{
action();
}
sw.Stop();
Console.Write("Name: {0},", name);
Console.Write(" Iterations: {1},", iterations);
Console.WriteLine(" Milliseconds: {2}", sw.ElapsedMilliseconds);
}
2.) Create your two test functions.
public void CompareWithParseInt()
{
int a = 1;
string b = "1";
bool isEqual = a == int.Parse(b);
}
public void CompareWithToString()
{
int a = 1;
string b = "1";
bool isEqual = a.ToString() == b;
}
3.) Now benchmark the crap out of them.
RunTest(CompareWithParseInt, "Compare With ParseInt", 1);
//Name: Compare With ParseInt, Iterations: 1, Milliseconds: 0
RunTest(CompareWithParseInt, "Compare With ParseInt", 1);
//Name: Compare With ParseInt, Iterations: 1, Milliseconds: 0
RunTest(CompareWithParseInt, "Compare With ParseInt", 10);
//Name: Compare With ParseInt, Iterations: 10, Milliseconds: 0
RunTest(CompareWithParseInt, "Compare With ParseInt", 100);
//Name: Compare With ParseInt, Iterations: 100, Milliseconds: 0
RunTest(CompareWithParseInt, "Compare With ParseInt", 1000);
//Name: Compare With ParseInt, Iterations: 1000, Milliseconds: 0
RunTest(CompareWithParseInt, "Compare With ParseInt", 100000);
//Name: Compare With ParseInt, Iterations: 100000, Milliseconds: 12
RunTest(CompareWithParseInt, "Compare With ParseInt", 1000000);
//Name: Compare With ParseInt, Iterations: 1000000, Milliseconds: 133
RunTest(CompareWithToString, "Compare With ToString", 1000000);
//Name: Compare With ToString, Iterations: 1000000, Milliseconds: 112
RunTest(CompareWithToString, "Compare With ToString", 100000000);
//Name: Compare With ToString, Iterations: 100000000, Milliseconds: 10116
RunTest(CompareWithParseInt, "Compare With ParseInt", 100000000);
//Name: Compare With ParseInt, Iterations: 100000000, Milliseconds: 12447
Conclusion:
As you can see in this particular case, you can pretty much do whatever makes you happy because if there is a bottleneck in your application. It's not with the above code :)