예제 #1
0
파일: Second.cs 프로젝트: yabols/Netling
        public void AddMerged(Second second)
        {
            Count += second.Count;
            Bytes += second.Bytes;

            foreach (var statusCode in second.StatusCodes)
            {
                if (StatusCodes.ContainsKey(statusCode.Key))
                {
                    StatusCodes[statusCode.Key] += statusCode.Value;
                }
                else
                {
                    StatusCodes.Add(statusCode.Key, statusCode.Value);
                }
            }

            foreach (var exception in second.Exceptions)
            {
                if (Exceptions.ContainsKey(exception.Key))
                {
                    Exceptions[exception.Key] += exception.Value;
                }
                else
                {
                    Exceptions.Add(exception.Key, exception.Value);
                }
            }
        }
예제 #2
0
        private void AddOrUpdateStatusCode(int statusCode)
        {
            if (statusCode == 0)
            {
                return;
            }

            if (!StatusCodes.ContainsKey(statusCode))
            {
                StatusCodes.Add(statusCode, 0);
            }

            StatusCodes[statusCode]++;
        }
예제 #3
0
        internal void Process(CombinedWorkerThreadResult wtResult)
        {
            Seconds = wtResult.Seconds;
            var items = wtResult.Seconds.Select(r => r.Value).DefaultIfEmpty(new Second(0)).ToList();

            Count             = items.Sum(s => s.Count);
            RequestsPerSecond = Count / (Elapsed.TotalMilliseconds / 1000);
            BytesPrSecond     = items.Sum(s => s.Bytes) / (Elapsed.TotalMilliseconds / 1000);

            foreach (var statusCode in items.SelectMany(s => s.StatusCodes))
            {
                if (StatusCodes.ContainsKey(statusCode.Key))
                {
                    StatusCodes[statusCode.Key] += statusCode.Value;
                }
                else
                {
                    StatusCodes.Add(statusCode.Key, statusCode.Value);
                }
            }

            foreach (var exception in items.SelectMany(s => s.Exceptions))
            {
                if (Exceptions.ContainsKey(exception.Key))
                {
                    Exceptions[exception.Key] += exception.Value;
                }
                else
                {
                    Exceptions.Add(exception.Key, exception.Value);
                }
            }

            Errors = StatusCodes.Where(s => s.Key >= 400).Sum(s => s.Value) + Exceptions.Sum(e => e.Value);

            var responseTimes = GetResponseTimes(wtResult.ResponseTimes);

            if (!responseTimes.Any())
            {
                return;
            }

            Median    = responseTimes.GetMedian();
            StdDev    = responseTimes.GetStdDev();
            Min       = responseTimes.First();
            Max       = responseTimes.Last();
            Histogram = GenerateHistogram(responseTimes);
        }
예제 #4
0
파일: Second.cs 프로젝트: yabols/Netling
        public void Add(long bytes, float responseTime, int statusCode, bool trackResponseTime)
        {
            Count++;
            Bytes += bytes;

            if (trackResponseTime)
            {
                ResponseTimes.Add(responseTime);
            }

            if (StatusCodes.ContainsKey(statusCode))
            {
                StatusCodes[statusCode]++;
            }
            else
            {
                StatusCodes.Add(statusCode, 1);
            }
        }
예제 #5
0
        public void Process(CombinedAgentThreadResult atResult)
        {
            Elapsed = atResult.Elapsed;
            var items = atResult.RequestStats.DefaultIfEmpty(new RequestStats()).ToList();

            Count             = atResult.Count;
            Errors            = atResult.Errors;
            RequestsPerSecond = Count / (Elapsed.TotalMilliseconds / 1000);
            BytesPrSecond     = items.Sum(s => s.Bytes) / (Elapsed.TotalMilliseconds / 1000);

            foreach (var statusCode in atResult.StatusCodes)
            {
                if (StatusCodes.ContainsKey(statusCode))
                {
                    StatusCodes[statusCode] += 1;
                }
                else
                {
                    StatusCodes.Add(statusCode, 1);
                }
            }

            var responseTimes = atResult.ResponseTimes.ToArray();

            if (!responseTimes.Any())
            {
                return;
            }

            Array.Sort(responseTimes);
            Median    = responseTimes.GetMedian();
            StdDev    = responseTimes.GetStdDev();
            Min       = responseTimes.First();
            Max       = responseTimes.Last();
            Histogram = GenerateHistogram(responseTimes);

            atResult.StartTimes.Sort((a, b) => a.CompareTo(b));
            FirstRequestTime = atResult.StartTimes.First();
            LastRequestTime  = atResult.StartTimes.Last();
            TimeSeries       = GenerateTimeSeries(atResult.StartTimes);
        }
예제 #6
0
        public void Add(DateTime startDateTimeUtc, DateTime endDateTimeUtc, bool isSuccessStatusCode, int statusCode, long headerLength, long responseLength, long requestSentTicks, long responseTicks, string responseHeaders, Exception exception)
        {
            lock (_lock) // TODO
            {
                StartDateTimes.Add(startDateTimeUtc);
                EndDateTimes.Add(endDateTimeUtc);
                IsSuccessStatusCodes.Add(isSuccessStatusCode);
                StatusCodes.Add(statusCode);
                HeaderLengths.Add(headerLength);
                ResponseLengths.Add(responseLength);
                RequestSentTicks.Add(requestSentTicks);
                ResponseTicks.Add(responseTicks);

                if (string.IsNullOrWhiteSpace(responseHeaders) == false)
                {
                    ResponseHeaders.Add(responseHeaders);
                }
                if (exception != null)
                {
                    Exceptions.Add(exception);
                }
            }
        }