Skip to content

Instantly share code, notes, and snippets.

@kmteam
Last active February 2, 2016 09:34
Show Gist options
  • Save kmteam/49ae6c6b60ffbfc5c875 to your computer and use it in GitHub Desktop.
Save kmteam/49ae6c6b60ffbfc5c875 to your computer and use it in GitHub Desktop.
Mesure time Consumption of pice of code
/// <summary>
/// Mesure time compsumption of piece of code
/// </summary>
/// <param name="action">Method to test (must be a method without parameters)</param>
/// <returns></returns>private TimeSpan Mesure(Action action)
public static TimeSpan Mesure(this Stopwatch watch,Action action)
{
watch.Start();
action();
watch.Stop();
return watch.Elapsed;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment