public void AddStatisticsDataPoint(RequestStatistics.RequestStatItem name, DateTime startTime, DateTime endTime)
 {
     if (this.statisticsDataPoints.ContainsKey(name))
     {
         this.statisticsDataPoints[name] = new RequestStatistics.StatisticsDataPoint(name, startTime, endTime);
         return;
     }
     this.statisticsDataPoints.Add(name, new RequestStatistics.StatisticsDataPoint(name, startTime, endTime));
 }
 public string GetStatisticsDataPointResult(RequestStatistics.RequestStatItem name)
 {
     if (this.statisticsDataPoints.ContainsKey(name))
     {
         RequestStatistics.StatisticsDataPoint statisticsDataPoint = this.statisticsDataPoints[name];
         return(string.Format("{0}({1})", statisticsDataPoint.EndTime.Subtract(statisticsDataPoint.StartTime).TotalMilliseconds, statisticsDataPoint.StartTime.ToString("hh:mm:ss.ffftt")));
     }
     return(string.Empty);
 }
        public static void Watch(RequestStatistics.RequestStatItem name, Action action)
        {
            DateTime utcNow = DateTime.UtcNow;

            action();
            if (HttpContext.Current != null && HttpContext.Current.Items != null)
            {
                RequestStatistics requestStatistics = HttpContext.Current.Items[RequestStatistics.RequestStatsKey] as RequestStatistics;
                if (requestStatistics != null)
                {
                    requestStatistics.AddStatisticsDataPoint(name, utcNow, DateTime.UtcNow);
                }
            }
        }
 public StatisticsDataPoint(RequestStatistics.RequestStatItem name, DateTime startTime, DateTime endTime)
 {
     this.Name      = name;
     this.StartTime = startTime;
     this.EndTime   = endTime;
 }