You can use JetBrains dotTrace to find bottle neck methods of your application. So, how to measure performance of specific method? .NET framework since version 2.0 has Stopwatch class in System.Diagnostics namespace. You can use following snippet to measure performance of your method:
public static void DummyLoop()
{
for (int i = 0; i < 1000; i++)
{
System.Threading.Thread.Sleep(2);
}
}
static void Main(string[] args)
{
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
DummyLoop();
stopWatch.Stop();
double ms = (stopWatch.ElapsedTicks * 1000.0) / Stopwatch.Frequency;
Console.WriteLine(string.Concat(ms.ToString(), " ms"));
Console.ReadLine();
}
And output would be:
2929.66815614834 ms