A simple benchmarking method to capture the start and end time of an action.
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
class Program
{
public static void TimeIt(Action action)
{
Stopwatch timer = Stopwatch.StartNew();
action();
timer.Stop();
Console.WriteLine("{0} took {1}", action.Method.Name, timer.Elapsed);
}
public static void DoSomething()
{
Thread.Sleep(3000);
}
static void Main(string[] args)
{
TimeIt(DoSomething);
}
}