Ejemplo n.º 1
0
        private void AddOrUpdateStatusCode(int statusCode)
        {
            if (statusCode == 0)
            {
                return;
            }

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

            StatusCodes[statusCode]++;
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
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);
        }