using System.Diagnostics; public class Profiler { public static async Task Run(string name, Func action) { Console.Write(name); var stopwatch = new Stopwatch(); stopwatch.Start(); await action(); stopwatch.Stop(); Console.WriteLine(" (" + stopwatch.ElapsedMilliseconds + "ms)"); } }