How to measure code performance in c# by measuring execution time.
using System.Diagnostics;
Stopwatch sw = new Stopwatch();
sw.Start();
// ... Your code to test goes here...
sw.Stop();
Console.WriteLine("Elapsed={0}",sw.Elapsed); // Print the result.