Measure Method Time Performance

Quick snippet to let you check the time used by any method you have.

public static void CalculateTime( Action method )
    Stopwatch chrono = new Stopwatch();

    Console.WriteLine("Method : " + method.Method.Name + ", Time: " + chrono.ElapsedMilliseconds + " (ms)");

This will write to the console the time spent on the method.

DiagnosticStaticClass.CalculateTime( MyExpensiveMethod );

Just remember to use System.Diagnostics.
More info on Stopwatch.

That’s it. Enjoy.