private T ProfileActivity <T>(string activityName, Func <T> activity, object arguments = null) { if (!ProfilingEnabled) { return(activity()); } var startTime = DateTime.UtcNow; var stopwatch = Stopwatch.StartNew(); var result = activity(); stopwatch.Stop(); var message = new Messages.ConnectionActivity { ConnectionName = this.Connection.ConnectionName, Name = activityName, ElapsedMilliseconds = stopwatch.ElapsedMilliseconds, Arguments = arguments, Results = result }; InspectorContext.MessageBroker.Publish(message); Timeline(activityName, new TimerResult { StartTime = startTime, Offset = startTime.Subtract(InspectorContext.TimerStrategy().RequestStart.ToUniversalTime()), Duration = stopwatch.Elapsed }); return(result); }
public void Setup(IInspectorContext context) { Profiler.MessageBroker = context.MessageBroker; Profiler.ExecutionTimerFactory = () => { try { return(context.TimerStrategy()); } catch { // Avoid exception being thrown from threads without access to request store return(null); } };; }
protected TimelineBase(IInspectorContext context) { _messageBroker = context.MessageBroker; _timer = context.TimerStrategy(); _offset = _timer.Point().Offset; }
protected TimelineBase(IInspectorContext context) { _messageBroker = context.MessageBroker; _timer = context.TimerStrategy(); _offset = _timer.Point().Offset; }