I found a simple code to know the execution time of a method. First of all you have to import the following namespace:
using System.Diagnostics;
Then you use Stopwatch to know the execution time.
Stopwatch sw = Stopwatch.StartNew(); DoSomeWork(); sw.Stop(); Console.WriteLine("Time taken: {0}ms", sw.Elapsed.TotalMilliseconds);
Happy coding!