Skip to content

Instantly share code, notes, and snippets.

@zxsanny
Last active February 17, 2022 14:40
Show Gist options
  • Save zxsanny/75849bbd98129612c9f87bc5dd06b187 to your computer and use it in GitHub Desktop.
Save zxsanny/75849bbd98129612c9f87bc5dd06b187 to your computer and use it in GitHub Desktop.
TimeSpan PerformanceTest(Action action, int repeats)
{
var sw = new Stopwatch();
sw.Start();
for (int i = 0; i < repeats; i++)
action();
sw.Stop();
return sw.Elapsed;
}
(TimeSpan action1, TimeSpan action2) ComparePerformanceTest(Action action1, Action action2, int repeats) =>
(PerformanceTest(action1, repeats), PerformanceTest(action2, repeats));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment