Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }