I want to measure the execution of a piece of code and I\'m wondering what the best method to do this is?
Option 1:
DateTime StartTime = DateTime.Now
Use below code
DateTime dExecutionTime; dExecutionTime = DateTime.Now; TimeSpan span = DateTime.Now.Subtract(dExecutionTime); lblExecutinTime.Text = "total time taken " + Math.Round(span.TotalMinutes,2) + " minutes . >>---> " + DateTime.Now.ToShortTimeString();