Profiler.cs 346 B

123456789101112
  1. using System.Diagnostics;
  2. public class Profiler {
  3. public static async Task Run(string name, Func<Task> action) {
  4. Console.Write(name);
  5. var stopwatch = new Stopwatch();
  6. stopwatch.Start();
  7. await action();
  8. stopwatch.Stop();
  9. Console.WriteLine(" (" + stopwatch.ElapsedMilliseconds + "ms)");
  10. }
  11. }