public TimeSpan UsingMarker(string name, Action action, PerformanceMarkerArea area = PerformanceMarkerArea.Unknown, string tag = null) { var marker = StartMarker(name, area, tag); using (marker) { action(); } return(marker.Elapsed.GetValueOrDefault()); }
/// <summary> /// We keep track of stopwatches which have an Elapsed value and we sum them by area. /// </summary> /// <param name="pm"></param> public void AppendMarker(IPerformanceMarker pm) { if (pm.Type == PerformanceMarkerType.Stopwatch && pm.Elapsed.HasValue) { PerformanceMarkerArea currentArea = pm.Area; double elapsed = pm.Elapsed.Value.TotalMilliseconds; AggregatesInMilliseconds[(int)currentArea] += elapsed; TryUpdateMetaData(pm.Timestamp, pm.RequestId, pm.SessionId); } }
public PerformanceMarker(string id, string name, DateTime timestamp, string requestId, string sessionId, PerformanceMarkerArea area = PerformanceMarkerArea.Unknown, string tag = null) { Id = id; Name = name; Timestamp = timestamp; RequestId = requestId; SessionId = sessionId; Area = area; Tag = tag; }
public IPerformanceMarker StartMarker(string name, PerformanceMarkerArea area = PerformanceMarkerArea.Unknown, string tag = null) { return(new StopwatchPerformanceMarker(this, GetId(), name, GetTimestamp(), GetRequestId(), GetSessionId(), area, tag)); }
public void AddMarker(string name, PerformanceMarkerArea area = PerformanceMarkerArea.Unknown, string tag = null) { _logger.Log(new PerformanceMarker(GetId(), name, GetTimestamp(), GetRequestId(), GetSessionId(), area, tag)); }
public StopwatchPerformanceMarker(IPerformanceProfiler profiler, string id, string name, DateTime timestamp, string requestId, string sessionId, PerformanceMarkerArea area = PerformanceMarkerArea.Unknown, string tag = null) : base(id, name, timestamp, requestId, sessionId, area, tag) { if (profiler == null) { throw new ArgumentNullException("profiler"); } _profiler = profiler; _stopwatch = Stopwatch.StartNew(); }
//When Logging perf marker, to avoid calling theEnum.ToString() we can just call PerformanceMarkerAreaHelper.AreaEnumToString(theEnum) public static string AreaEnumToString(PerformanceMarkerArea e) { return(AreaNames[(int)e]); }