protected T Profile <T>(String label, Func <T> func) { label = FormatProfileLabel(label); DateTime start = DateTime.UtcNow; T result = func(); var duration = DateTime.UtcNow - start; Profiling.AddRecord(label, duration); ProfilingEntries.TryAdd(label, duration); logger.LogDebug("{0} took {1}ms", label, (int)duration.TotalMilliseconds); return(result); }
protected void Profile(String label, Action action) { label = FormatProfileLabel(label); DateTime start = DateTime.UtcNow; action(); var duration = DateTime.UtcNow - start; Profiling.AddRecord(label, duration); ProfilingEntries.TryAdd(label, duration); logger.LogDebug("{0} took {1}ms", label, (int)duration.TotalMilliseconds); }
protected async Task Profile(String label, Func <Task> func) { label = FormatProfileLabel(label); DateTime start = DateTime.UtcNow; await func(); var duration = DateTime.UtcNow - start; Profiling.AddRecord(label, duration); ProfilingEntries.TryAdd(label, duration); logger.LogDebug("{0} took {1}ms", label, (int)duration.TotalMilliseconds); }