public void SetPerformanceMeasurePoint(string name, string pointName) { try { if (HttpContext.Current == null) return; Dictionary<string, PerformanceInfo> info = HttpContext.Current.Items[AppInfoCenterConfiguration.Const.ContextPerformanceMeasureKey] as Dictionary<string, PerformanceInfo>; if (info == null || !info.ContainsKey(name)) return; PerformanceInfo pi = info[name]; var time = GetCurrentThreadTimes(); var ppItem = new PerformancePointItem { CPUTime = (time - pi.threadTime) * 100, TimeElapsed = pi.sw.ElapsedMilliseconds, Time = DateTime.Now, }; pi.threadTime = time; pi.sw = Stopwatch.StartNew(); if (!pi.PerformancePoints.ContainsKey(pointName)) { pi.PerformancePoints[pointName] = new PerformancePoint { PerformancePointItems = new List<PerformancePointItem>(), }; } pi.PerformancePoints[pointName].PerformancePointItems.Add(ppItem); HttpContext.Current.Items[AppInfoCenterConfiguration.Const.ContextPerformanceMeasureKey] = info; } catch (Exception ex) { ex.Handle(AppInfoCenterService.ModuleName, ServiceName, "SetPerformanceMeasurePoint"); } }
public void SetPerformanceMeasurePoint(string name, string pointName) { try { if (HttpContext.Current == null) { return; } Dictionary <string, PerformanceInfo> info = HttpContext.Current.Items[AppInfoCenterConfiguration.Const.ContextPerformanceMeasureKey] as Dictionary <string, PerformanceInfo>; if (info == null || !info.ContainsKey(name)) { return; } PerformanceInfo pi = info[name]; var time = GetCurrentThreadTimes(); var ppItem = new PerformancePointItem { CPUTime = (time - pi.threadTime) * 100, TimeElapsed = pi.sw.ElapsedMilliseconds, Time = DateTime.Now, }; pi.threadTime = time; pi.sw = Stopwatch.StartNew(); if (!pi.PerformancePoints.ContainsKey(pointName)) { pi.PerformancePoints[pointName] = new PerformancePoint { PerformancePointItems = new List <PerformancePointItem>(), }; } pi.PerformancePoints[pointName].PerformancePointItems.Add(ppItem); HttpContext.Current.Items[AppInfoCenterConfiguration.Const.ContextPerformanceMeasureKey] = info; } catch (Exception ex) { ex.Handle(AppInfoCenterService.ModuleName, ServiceName, "SetPerformanceMeasurePoint"); } }