private static void PostRequestHandlerExecuteHandler(object sender, EventArgs e) { var context = sender as HttpContext; if (context == null) { return; } if (PageStopwatch == null) { return; } PageStopwatch.Stop(); var result = new UriExecutionTime(context.Request.RawUrl, PageStopwatch.ElapsedMilliseconds); // 실행 결과를 Producing 합니다. _pageExecutionResults.TryAdd(result); if (IsDebugEnabled) { log.Debug("Page 처리에 대한 성능 측정을 완료했습니다. Request=[{0}], ExecutionTime=[{1}]", result.UriString, result.ExecutionTime); } }
/// <summary> /// 페이지별 처리 빈도 수를 설정합니다. /// </summary> /// <param name="frequencies"></param> /// <param name="result"></param> private static void UpdateExecutionFrequency(ConcurrentDictionary <string, int> frequencies, UriExecutionTime result) { frequencies.AddOrUpdate(result.UriString, 1, (key, value) => value + 1); }
/// <summary> /// 요청 Uri 별 평균 처리 시간을 Update합니다. /// </summary> /// <param name="executionTimes">실행 결과 순위</param> /// <param name="result">새로운 처리 결과</param> private static void UpdateExecutionTime(ConcurrentDictionary <string, long> executionTimes, UriExecutionTime result) { Func <string, long, long> @updateFunc = (key, time) => (RankByTotalTime) ? time + result.ExecutionTime : (executionTimes[key] + result.ExecutionTime) / 2; executionTimes.AddOrUpdate(result.UriString, result.ExecutionTime, @updateFunc); //if(executionTimes.ContainsKey(result.UriString)) //{ // if(RankByTotalTime) // executionTimes[result.UriString] += result.ExecutionTime; // else // executionTimes[result.UriString] = (executionTimes[result.UriString] + result.ExecutionTime) / 2L; //} //else // executionTimes.Add(result.UriString, result.ExecutionTime); }